首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >开发游戏

开发游戏
EN

Stack Overflow用户
提问于 2011-08-05 17:32:47
回答 1查看 411关注 0票数 0

我正在使用libgdx开发一个基于触摸的game.In我的游戏,我想保存状态,并希望在某个特定的时间恢复它。在libgdx中有没有其他方法?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-08-05 18:06:50

如果保存状态是指保存和加载设置/首选项,请使用this

代码语言:javascript
复制
Preferences prefs = Gdx.app.getPreferences("my-preferences");
prefs.putBoolean("bool", true);
prefs.putInteger("int", 1234);
prefs.putLong("long", Long.MAX_VALUE);
prefs.putFloat("float", 1.2345f);
prefs.putString("string", "test!");

if(prefs.getBoolean("bool") != true) throw new GdxRuntimeException("bool failed");
if(prefs.getInteger("int") != 1234) throw new GdxRuntimeException("int failed");
if(prefs.getLong("long") != Long.MAX_VALUE) throw new GdxRuntimeException("long failed");
if(prefs.getFloat("float") != 1.2345f) throw new GdxRuntimeException("float failed");
if(!prefs.getString("string").equals("test!")) throw new GdxRuntimeException("string failed");
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6954235

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档