暂停后保存游戏状态。 AndEngine [英] Save game state after pause. AndEngine

查看:199
本文介绍了暂停后保存游戏状态。 AndEngine的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现,恢复比赛后,所有的引擎重新加载和应用被重新初始化。 我要救发动机状态和onResume恢复比赛proccess。

i've found that after resuming the game all the engine is reloaded and application is reinitialized. I want to save engine state and in "onResume" resume the game proccess.

我试图拯救所有的发动机(mEngine),然后重新开始后,本场比赛中的onLoadEngine回归保存引擎。我认为这是一个坏的解决方案,这是行不通的。

I've tried to save all the engine (mEngine) and then after resume the game in "onLoadEngine" return saved engine. I think it is a bad solution and it doesn't work

什么是暂停的最佳解决方案\恢复比赛在andEngine?

What is the best solution for Pause\Resume the game (after power key pressed for example) in andEngine ?

推荐答案

我找到的解决方案是序列化引擎JSON的状态,并保存为共享存储。 其大量的工作,但它确实保存。由于andengine是要重新初始化你的引擎和纹理暂停后,我觉得不会有太多的选择,除非你想重新写的一些andengine为你的游戏。 (可以)

The solution I found was to serialize the state of the engine as JSON and save it as shared storage. Its a lot of work, but it does save it. Since andengine is going to re-init your engine and textures after a pause, I think there are not many choices, unless you want to re-write some of andengine for your game. (which you can)

在我的JSON我记录每个精灵的位置型速度等。该怎样获取保存的复杂性依赖于你的游戏的复杂性。然后给每个班级我补充说,接受JSON输入一个Deserialize方法。

In my JSON I record the position type velocity etc of each sprite. The complexity of what gets saved depends on the complexity of your game. And then to each class I added a deserialize method that accepts the JSON as input.

作为一个脚注的方法,我不能作出了一个更简单的任务给予高度足够惊人GSON库。 HTTP://$c$c.google.com/p/google-gson/

As a footnote to that method, I cannot speak highly enough of the amazing GSON library for making that an easier task. http://code.google.com/p/google-gson/

但恢复的记住比赛的时候,设置恢复状态,以暂停,以便用户知道什么时候游戏会重新开始。

But remeber when restoring the game, to set the restored state to paused so the user knows when the game will re-commence.

这篇关于暂停后保存游戏状态。 AndEngine的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆