如何从Libgdx动态调用override pause方法?

How to call the override pause method dynamically from Libgdx?

我创建了一个 Libgdx 游戏,我想知道是否可以使用 Libgdx 调用覆盖暂停方法生命周期?

这是我 class 中的暂停方法生命周期:

public class MyGdxGame extends ApplicationAdapter {
    @Override
    public void pause() {
        super.pause();
        chrono.pause();
        //Display a pause menu
    }
}

而且我想在点击暂停图片时调用生命周期方法:

    imagePause = new Image(new Texture(Gdx.files.internal("pause.png")));
    imagePause.setSize(pauseSize, pauseSize);
    imagePause.setPosition(width - pauseSize, height - pauseSize);
    imagePause.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            //Something like this? :
            Gdx.app.pause(); //Doesn't exist

            //I don't want to call manually the pause method like this       
            //because it doesn't pause Libgdx lifecycle ...
            pause();
        }
    });
    stage.addActor(imagePause);

有什么想法吗?

如果您的目标停止 渲染:

要停止渲染:

Gdx.graphics.setContinuousRendering(false);

要装回去:

Gdx.graphics.setContinuousRendering(true);

渲染停止时触发渲染:

Gdx.graphics.requestRendering();

文档:https://github.com/libgdx/libgdx/wiki/Continuous-&-non-continuous-rendering

希望对您有所帮助。