0

I made a game using Andengine. How can I add a pause/resume button to it?

I researched this but I couldn't understand exactly. I can stop the game with the code below, but then I can't resume it again.

    pause = new Sprite(400.0f, 200.0f, pauseTextReg){
        @Override
        public boolean onAreaTouched(final TouchEvent pAreaTouchEvent, final float pTouchAreaLocalX, final float pTouchAreaLocalY) {
            switch(pAreaTouchEvent.getAction()) {
            case TouchEvent.ACTION_DOWN:

                mEngine.stop();

                break;
            }
            return true;
        }
    };
    scene.registerTouchArea(pause);
    scene.getLastChild().attachChild(pause);

    resume = new Sprite(400.0f, 250.0f, resumeTextReg){
        @Override
        public boolean onAreaTouched(final TouchEvent pAreaTouchEvent, final float pTouchAreaLocalX, final float pTouchAreaLocalY) {
            switch(pAreaTouchEvent.getAction()) {
            case TouchEvent.ACTION_DOWN:

                mEngine.start();

                break;
            }
            return true;
        }
    };
    scene.registerTouchArea(resume);
    scene.getLastChild().attachChild(resume);
WhiteKnight
  • 4,938
  • 5
  • 37
  • 41
Kadir
  • 411
  • 1
  • 6
  • 19

1 Answers1

0

it works but it doesn't answer the my purpose.because it just paused the elements which are on screen.In my game 10 sprites are creating in (-100,-100) coordinate.and moving the screen.so when i paused the game,sprites are creating and moving the screen and they are pausing when they are in (0,0) coordinate.

Kadir
  • 411
  • 1
  • 6
  • 19