我在 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();
}
我在 Engine 类中将它跟踪到这一行:
} 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