Reputation: 802
I create a Libgdx game and I want to know if it is possible to call the override pause method lifecycle with Libgdx?
Here is my pause method lifecycle in my class:
public class MyGdxGame extends ApplicationAdapter {
@Override
public void pause() {
super.pause();
chrono.pause();
//Display a pause menu
}
}
And I want to call the lifecycle method when I click on the pause image:
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);
Any idea?
Upvotes: 2
Views: 607
Reputation: 82
If your goal is to stop the render:
To stop the render:
Gdx.graphics.setContinuousRendering(false);
To put it back on:
Gdx.graphics.setContinuousRendering(true);
To trigger render when the rendering is stop:
Gdx.graphics.requestRendering();
Documentation: https://github.com/libgdx/libgdx/wiki/Continuous-&-non-continuous-rendering
Hope it will help you.
Upvotes: 1