我在AndEngine中使用了一個定時器,但它在我身上拋出了這個錯誤。AndEngine使用定時器時出錯
下面是從中拋出的錯誤方法:
public void onPopulateScene(Scene pScene,
OnPopulateSceneCallback pOnPopulateSceneCallback) throws Exception {
mEngine.registerUpdateHandler(new TimerHandler(3f,
new ITimerCallback() {
@Override
public void onTimePassed(final TimerHandler pTimerHandler) {
SceneManager.getInstance().createMenuScene();
mEngine.unregisterUpdateHandler(pTimerHandler);
}
}));
pOnPopulateSceneCallback.onPopulateSceneFinished();
}
我的引擎類就追蹤到這條線的位置:
} finally {
this.mEngineLock.unlock();
}
誰能幫助?
02-21 03:39:55.056: E/AndroidRuntime(27796): FATAL EXCEPTION: UpdateThread
02-21 03:39:55.056: E/AndroidRuntime(27796): java.lang.NullPointerException
02-21 03:39:55.056: E/AndroidRuntime(27796): at edu.ian.andenginetest.SceneManager.disposeSplashScene(SceneManager.java:50)
02-21 03:39:55.056: E/AndroidRuntime(27796): at edu.ian.andenginetest.SceneManager.createMenuScene(SceneManager.java:57)
02-21 03:39:55.056: E/AndroidRuntime(27796): at edu.ian.andenginetest.MainActivity$1.onTimePassed(MainActivity.java:73)
02-21 03:39:55.056: E/AndroidRuntime(27796): at org.andengine.engine.handler.timer.TimerHandler.onUpdate(TimerHandler.java:98)
02-21 03:39:55.056: E/AndroidRuntime(27796): at org.andengine.engine.handler.UpdateHandlerList.onUpdate(UpdateHandlerList.java:47)
02-21 03:39:55.056: E/AndroidRuntime(27796): at org.andengine.engine.Engine.onUpdateUpdateHandlers(Engine.java:597)
02-21 03:39:55.056: E/AndroidRuntime(27796): at org.andengine.engine.Engine.onUpdate(Engine.java:585)
02-21 03:39:55.056: E/AndroidRuntime(27796): at org.andengine.engine.LimitedFPSEngine.onUpdate(LimitedFPSEngine.java:56)
02-21 03:39:55.056: E/AndroidRuntime(27796): at org.andengine.engine.Engine.onTickUpdate(Engine.java:548)
02-21 03:39:55.056: E/AndroidRuntime(27796): at org.andengine.engine.Engine$UpdateThread.run(Engine.java:820)
下面是GitHub的鏈接提交我的代碼:https://github.com/mkaziz/EECS-499---Android-Shooter/commit/63dab77fe43f70543b06ea6436249c8401b339bc
感謝您的迴應!我相信'OnTimePassed()'本質上等同於'onFinished()'。我創建一個實例的特定接口甚至沒有任何其他方法。 – khalid13 2013-02-22 01:06:18
@ khalid13讓我知道是否通過移動到更新線程來解決問題。 – 2013-02-22 01:25:41
@khalid看起來像有正確的答案。你沒有告訴我們關於github代碼! – 2013-02-22 02:52:01