我正在使用libgdx开发一个基于触摸的game.In我的游戏,我想保存状态,并希望在某个特定的时间恢复它。在libgdx中有没有其他方法?
发布于 2011-08-05 18:06:50
如果保存状态是指保存和加载设置/首选项,请使用this:
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");https://stackoverflow.com/questions/6954235
复制相似问题