【问题标题】:How to pass changing int value from one class to another libgdx如何将更改的 int 值从一个类传递到另一个 libgdx
【发布时间】:2015-12-29 07:43:44
【问题描述】:

我需要将我的 score int 值传递到另一个屏幕。我尝试使用:

public void setScore(int score) {
    this.score = score;
}

public int getScore() {
    return score;
} 
public void render(float delta){
    Gdx.gl.glClearColor(1, 1, 1, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
    setScore(score);

}

在另一个类中

int score = 0;
public end(Gamechanger gam){  
MyGdxGame mygame = new MyGdxGame(game);    
score = mygame.getscore(); 

}

但是当我玩的时候,分数是0。

也试过

public void render(float delta){
score = mygame.score;

}

但结果相同。

【问题讨论】:

    标签: java libgdx


    【解决方案1】:

    您可以为此使用首选项:

    https://github.com/libgdx/libgdx/wiki/Preferences

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-11-29
      • 2013-03-16
      • 2011-08-26
      • 2017-10-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多