I want something to happen in every step/frame/time-unit of my game. What's the easiest way to do so?


In the method onLoadScene(), add a UpdateHandler.

scene.registerUpdateHandler(new TimerHandler(1f / 20.0f, true, new ITimerCallback() {
                public void onTimePassed(final TimerHandler pTimerHandler) {

                    //Place what you want to happen here!



scene.registerUpdateHandler(new IUpdateHandler() {
                public void onUpdate(float pSecondsElapsed) {
                //Place what you want to happen here!

The TimerHandler lets you decide how often you want it to be updated while the IUpdateHandler updates simply whenever the game is updated.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License