1

私は初めてのゲームに取り組んでいます :)

libgdx を使用した Android ベースのゲームであり、DeWiTTERS ループの 1 つの変更例を使用しています。

ゲームループは、デスクトップ (59 - 60 fps) で実行すると完全に正常に動作するように見えますが、携帯電話で実行すると、75 - 90 FPS 程度になる傾向があります。

nextGameTick は、ゲーム ループが 60 FPS 以下で実行されるように、常に 16 ミリ秒先を参照する必要があります。

参考までに、ゲーム ループの主要部分を次に示します。

public void render() {
    nextGameTick = System.nanoTime() + skipTicks;
    loopTimeFull = System.nanoTime();

    Application app = Gdx.app;

    screen.update(app); // Update the screen
    screen.render(app); // Render the screen

    // when the screen is done we change to the
    // next screen
    if (screen.isDone()) {
        // dispose the current screen
        screen.dispose();
        <snip>
        // Removed unneded part of code for this example
        </snip>
        }
    }

    // Make the thread sleep
    General.renderTime = System.nanoTime() - loopTimeFull;
    while (System.nanoTime() <= nextGameTick - General.renderTime) {
        try {
            Thread.sleep(1);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    General.loopTime = System.nanoTime() - loopTimeFull;
    if (General.loopTime > 0)
        General.curFps = 1000000000 / General.loopTime;
    else
        Gdx.app.log("Air Offense", "General.loopTime == 0");
4

0 に答える 0