因此,当用户进行购买时,他们会获得一个可替换原始纹理的新纹理。我有点拉它。但是我也希望用户能够在需要时更换回原来的用户。
用户进行购买时,纹理变化正常。但是当我将这种变化存储在偏好中时,它会使其永久化。因此,当我尝试按下按钮以更改为原始石头时,只需调用“setStone(...)”,就不会发生任何事情。
任何可以看到我哪里出错的人? P.S代码不直接复制,只是切入重要部分。
ObjectMap<Integer, Texture> screenMap = new ObjectMap<Integer, Texture>();
ObjectMap<String, Boolean> mTexturesStatus = new ObjectMap<String, Boolean>();
public void setStone1() {
stoneImage = new Image(screenMap.get(0));
}
public void setStone(int screenId) {
stoneImage = new Image(screenMap.get(screenId));
}
screenMap.put(0, sdStone);
screenMap.put(1, stone_3);
mTexturesStatus.put("stone1", stone1);
mTexturesStatus.put("stone2", stone2);
btnArrow.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
game.setScreen(0);
//Saves the entered text.
Preferences prefs = Gdx.app.getPreferences("preferences");
prefs.putString("textField", textField.getText());
prefs.putString("textArea", textArea.getText());
prefs.getBoolean("stoneOne");
prefs.getBoolean("stoneTwo");
prefs.flush();
}
});
//screenMap.put(prefs.getInteger("stoneOne", 0), sdStone);
//screenMap.put(prefs.getInteger("stoneTwo", 1), stone_3);
setStone1();
if(stone1 = true) {
setStone(0);
prefs.putBoolean("stoneOne", true);
}
if(stone2 = true) {
setStone(1);
prefs.putBoolean("stoneTwo", true);
}
}