這是一個相當廣泛的問題,但有誰知道爲什麼對話框似乎影響Android上的幀率?例如,當我在遊戲運行時顯示和解除對話框時,運動變得緩慢且波濤洶涌。但是,遊戲內爆炸的幀率會提高。我試過了我能想到的每件事情,似乎沒有任何幫助。任何幫助大大讚賞。對話框和FPS更改
我怎麼顯示對話框:
private void showPauseMenu() {
isRunning = false; //tells the game thread that the game is no longer running
paused = true; //tells the game thread that the game is paused
ourThread = null; // nulls the Thread object until the game is resumed
pause.show();
}
我如何擺脫對話框,然後重新啓動遊戲:
isRunning = true;
ourThread = new Thread(this);
if (paused) {
paused = false;
pause.dismiss();
}
ourThread.start();
FPS計算
if (elapsedTime < 33) {
timeToSleep = 33 - elapsedTime;
} else {
timeToSleep = 0;
Log.i("fps", "sleeping over 33ms");
}
try {
Thread.sleep(timeToSleep);
} catch (InterruptedException e) {
e.printStackTrace();
}
Log.i("fps", "" + 1000/(elapsedTime + timeToSleep));
有人嗎?我在這裏絕望。 – ArmaAK
你使用OpenGL嗎? – yushulx
不,我不知道。我只是使用java的圖形。 – ArmaAK