AndEngine Game Loop. Where is it?

I have experience programming games with Cocos2d and Box2d. Now I am playing with AndEngine and I am a bit lost. This may sound like a silly question, but where is the AndEngine game loop? Where is the update () function that is usually found on other machines? I've gone through examples and I just can't seem to find it. I saw this example http://www.andengine.org/forums/development/where-is-the-game-loop-t12.html but it didn't help.

If you can shed some light on this, I would appreciate it.

+3


source to share


3 answers


// An easy way is to create a game loop using the onLoadScene method



public Scene onLoadScene() {     
            Scene scene = new Scene();                     
            scene.registerUpdateHandler(new IUpdateHandler() {                    
                public void reset() {        
                }             
                public void onUpdate(float pSecondsElapsed) {
                    //HERE IS THE GAME LOOP
                }
            });
            return scene;
}

      

+9


source


+1


source


You can also implement the IUpdateHandler interface in your Activity class:

public class YourActivityClass extends BaseGameActivity implements IUpdateHandler
{
    @Override
    public void onUpdate(float pSecondsElapsed)
    {
        //Game loop
    }

    @Override
    public void reset() 
    {   
    }
}

      

And register an update handler:

mEngine.registerUpdateHandler(this);

      

0


source







All Articles