0

我想知道这里的错误在哪里。我遵循了我认为有用但仍然错误的示例。

这是代码:

FPSCounter fpsCounter = new FPSCounter();

this.mEngine.registerUpdateHandler(fpsCounter);

final Scene scene = new Scene();
scene.setBackground(new Background(0.09804f, 0.6274f, 0.8784f));

final Text elapsedText = new Text(100, 160, this.mFont, "Seconds elapsed:", "Seconds elapsed: XXXXX".length(), this.getVertexBufferObjectManager());
final Text fpsText = new Text(250, 240, this.mFont, "FPS:", "FPS: XXXXX".length(), this.getVertexBufferObjectManager());

scene.attachChild(elapsedText);
scene.attachChild(fpsText);

scene.registerUpdateHandler(new TimerHandler(1 / 20.0f, true, new ITimerCallback() {
    @Override
    public void onTimePassed(final TimerHandler pTimerHandler) {
        elapsedText.setText("Seconds elapsed: " + MainActivity.this.mEngine.getSecondsElapsedTotal());
        fpsText.setText("FPS: " + fpsCounter.getFPS());
    }
}));

return scene;
4

0 回答 0