3

Greetings,

I am developing a game and i want to enable user to continue my game after he minimizes the app and resumes it, but i have run into a wall, and not sure what to do.

I have a pause/resume button that works great, and i did the same code when the activity is paused/resumed but that doesn't seem to help.

Altho my game doesn't crash when being brought to the front, nothing is happening ( even my buttons don't work ) it just shows the canvas as it was before the minimization.

Here is some of my code that i think is relevant to the situation.

If someone has any suggestions, please let me know. Thanks!

@Override
protected void onPause() {
    super.onPause();
    game.pause(); //game is the game thread
}

@Override
protected void onResume() {
    super.onResume();
    game.unpause();
}

And the pause/unpause methods :

public void pause() {
        setState(STATE_PAUSE); 
        cancelTimer();
        pauseFlag = true;
    }
    public void unpause(){
        setState(STATE_RUNNING);
        if(pauseFlag){
            startTimer(gap);
            pauseFlag = true;
        }
    }
Loktar
  • 34,764
  • 7
  • 90
  • 104
Pavle37
  • 571
  • 9
  • 24

0 Answers0