1

I try to create LUDO game and when user stop the game I want to save game state (Activity state).

I understood that I need to save state in method OnPause() but there are lots variables that I need to save and there are all changing in time so I am not sure that I can save state in that way.

So can I save the whole Activity and OnResume() method to restored it and just continue whith the game?

Thanks.

4

2 に答える 2

1

I think you are looking for How to save an Android application's state.

The documentation also provides details on saving persistent state with onPause.

于 2012-05-25T22:13:41.263 に答える
1

Don't know what you mean by changing in time. Are you saying your game progresses even while the player isn't playing? Normally, you would save only the minimum amount of information necessary to recreate the current state. For a board game, this could be the locations of each players' pieces, and whose turn it is.

If you really have so much game state that it would be unwieldy to save and restore, or the game has to progress while the Activity is closed, or recreating the state from static data is too difficult (all propositions I would probably dispute, but we can take it a given for the sake of discussion), then I would suggest you write it as a client-server app, where an Android Service runs the game engine and your Activity does all the visuals and user interaction.

于 2012-05-25T22:14:19.490 に答える