我正在做一个简单的游戏,当它第一次运行时它运行完美,没有问题,如果你完成一个关卡,高分屏幕就会打开(下面的 run() 方法),然后你下次玩游戏时它以大约五分之一的速度运行,然后是第一次。我有另一个线程,它是一个在两种情况下都能完美运行的计时器。我已经查看了代码,但找不到第二次运行速度变慢的任何原因?有任何想法吗?
下面是从菜单屏幕打开关卡的代码。
public void fieldChanged(Field inField, int inContext){
final int level;
if(inField == button1)
level = 1;
else
if(inField == button2)
level = 2;
else
if(inField == button3)
level = 3;
else
if(inField == button4)
level = 4;
else
level = 0; //Ensures variable is initialised
game = new Game(level);
UiApplication.getUiApplication().pushScreen(game);
_invokeID = getApplication().invokeLater(new Runnable(){
public void run(){
if (game.getActive() == false){
getApplication().cancelInvokeLater(_invokeID);
getUiEngine().popScreen(game);
Dialog.inform("Final Score: " + String.valueOf(game.getScore()));
hs = new HighScore(game.getScore(), game.getTime(), level);
UiApplication.getUiApplication().pushScreen(hs);
game = null;
}
}
}, 500,true);
}