Power Button Creating Issue in AndEngine Game [closed]

前提是你 提交于 2020-02-03 08:38:45

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!