电源按钮创建问题的AndEngine游戏按钮、电源、问题、游戏

2023-09-07 11:35:32 作者:得不到的从来都珍贵

我公司开发的游戏andEngine这几乎是最后的。唯一的问题我现在面临的是,当​​在游戏中,如果电源按钮是pressed和游戏重新开始再次它从恒星。假设我玩6级和I pressed电源按钮时,游戏会恢复它会从1级开始任何一个可以帮助我?

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?

推荐答案

您需要保存当前状态的onSaveInstanceState()并加载它 onRestoreInstanceState()。

You have to save current state in onSaveInstanceState() and load it in onRestoreInstanceState().

检查此链接: Android的活动

具体做法是:

活动周期 保存活动状态 Activity lifecycle Saving activity state