What methods should save/load a game state

Posted by vedi on Game Development See other posts from Game Development or by vedi
Published on 2012-02-15T20:58:22Z Indexed on 2012/09/14 21:49 UTC
Read the original article Hit count: 344

Filed under:
|
|
|

There are a lot of articles about how to save a state of a game and they are pretty good. But I have one conceptual misunderstanding where should I save the state?

My game has number of screens and pair of them are MainMenuScreen and MainSceneScreen these are inherited from Screen class. MainMenuScreen is shown at start of the game the MainSceneScreen little later.

What is the problem? I navigated to MainSceneScreen, forced Android to stop the application (I change a language settings on the device to achieve it, please let me know if I'm wrong). After that I select the application again and I can see MainMenuScreen is shown. But I want MainSceneScreen to be shown.

I suppose I should override resume method. But what class I should override? I have class PsGame that extends Game class of libgdx. I put breakpoints to its resume method and it turned out that method was not called. I investigated the problem and I've found little strange code in onResume method of AndroidApplication class of libgdx:

    if (!firstResume)
        graphics.resume();
    else
        firstResume = false;

My debugger said firstResume was true and didn't go to *graphics.resume()*line.

Sorry for a lot of words but could you answer following question:

  1. What did I do wrong?
  2. What methods should I override?

Thank you in advance.

© Game Development or respective owner

Related posts about android

Related posts about state