问题
I developed a game in andEngine which is almost final. Only problem I am facing now is that when during GamePlay if power button is pressed and Game is resumed again It starts from star. Suppose I am playing Level 6 and I pressed power button when the game will be resumed it will start from Level 1. Can any one help me with this?
回答1:
You have to save current state in onSaveInstanceState() and load it in onRestoreInstanceState().
Check this link: Android activities
Specifically:
- Activity lifecycle
- Saving activity state
回答2:
The main activity detects when it is being paused and taken out of memory. Look into the Activity onPause() and onResume().
来源:https://stackoverflow.com/questions/8950918/power-button-creating-issue-in-andengine-game