保存游戏状态的Andr​​oid [英] Saving Game state Android

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

问题描述

我不确定我应该如何保存我的游戏的游戏状态,我正在开发。我要救一个包含所有游戏信息的实例/对象吗?如果是的话,怎么样?或者我应该保存所有相关信息以.txt文件并保存/载入信息,在需要的时候?

I'm unsure how I'm supposed to save the game state of my game that I'm developing. Should I save a instance/object containing all the game information? If yes, how? Or should I save all the relative information in a .txt file and save/load information when needed?

你是怎么做到这一点,您怎么看我的建议?

How do you do this and what do you think of my proposals?

推荐答案

除非你序列化并保存到一些文本/二进制文件/数据库文件无法保存的实例/对象。你的两个选项是一种相同的,因此

You can't save an Instance / Object unless you serialize it and save it to some text/binary/database file. Your two options are kind of identical therefore.

您需要保存什么是你需要重建你的游戏状态的所有信息。有可能是你可以从这里得到一些信息。

What you need to save is all information that you need to reconstruct your game state. There are probably some information that you can derive from here.

如果你只是一个小的固定组定义你的游戏状态,然后使用共享preferences变量。

If you have just a small fixed set of variables that define your gamestate then use SharedPreferences.

如果你想保持一个以上的国家和/或更复杂的节省使用一些文本(XML,JSON,...)/二进制文件/数据库/ ..再presentation并存储。

If you want to keep more than one state and / or it is more complex to save use some text (xml, json, ...)/binary/database/.. representation and store that.

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

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