Sunday, 15 July 2012

android - AndEngine Error in using Timer -



android - AndEngine Error in using Timer -

i'm using timer within andengine, it's tossing error @ me.

here's method error beingness thrown:

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(); }

i've tracked line here in engine class:

} { this.menginelock.unlock(); }

can help?

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): @ edu.ian.andenginetest.scenemanager.disposesplashscene(scenemanager.java:50) 02-21 03:39:55.056: e/androidruntime(27796): @ edu.ian.andenginetest.scenemanager.createmenuscene(scenemanager.java:57) 02-21 03:39:55.056: e/androidruntime(27796): @ edu.ian.andenginetest.mainactivity$1.ontimepassed(mainactivity.java:73) 02-21 03:39:55.056: e/androidruntime(27796): @ org.andengine.engine.handler.timer.timerhandler.onupdate(timerhandler.java:98) 02-21 03:39:55.056: e/androidruntime(27796): @ org.andengine.engine.handler.updatehandlerlist.onupdate(updatehandlerlist.java:47) 02-21 03:39:55.056: e/androidruntime(27796): @ org.andengine.engine.engine.onupdateupdatehandlers(engine.java:597) 02-21 03:39:55.056: e/androidruntime(27796): @ org.andengine.engine.engine.onupdate(engine.java:585) 02-21 03:39:55.056: e/androidruntime(27796): @ org.andengine.engine.limitedfpsengine.onupdate(limitedfpsengine.java:56) 02-21 03:39:55.056: e/androidruntime(27796): @ org.andengine.engine.engine.ontickupdate(engine.java:548) 02-21 03:39:55.056: e/androidruntime(27796): @ org.andengine.engine.engine$updatethread.run(engine.java:820)

here's link github commit code: https://github.com/mkaziz/eecs-499---android-shooter/commit/63dab77fe43f70543b06ea6436249c8401b339bc

according code on github (you left on andengine forum, not here): in mainactivity class oncreatescene() function, phone call scenemanager's createsplashscene() executes andengine oncreatescenefinished() callback once. and, after homecoming oncreatescene() in mainactivity, execute same callback again. if trace andengine code, know cause onpopulatescene() in mainactivity executes twice too. so, you'll create 2 timer instances, , npe when sec timer disposing splash screen.

android andengine

No comments:

Post a Comment