How do i pause my game?
I know its newbie but i didnt implemented that yet…
Is there any correct way
?
How do i pause my game?
I know its newbie but i didnt implemented that yet…
Is there any correct way
?
Erm… vague much?
What libraries, frameworks, code are you using?
If your code is designed properly, you could try not calling update on other classes.
But its important you separated update logic (movement, collisions etc) from drawing (only drawing stuff).
if(!paused)
{
game.update();
}
if (keycode == Keys.P) {
if (current_Level.isPaused == true) {
current_Level.resume();
} else {
current_Level.pause();
}
}
@Override
public void pause() {
isPaused = true;
soundtrack.get(0).pause();
}
@Override
public void resume() {
isPaused = false;
soundtrack.get(0).play();
}
@Override
public void render(float delta) {
if (isPaused == false) {
....
}
And it works like a charm, thanks robin and thanks Terabytes haha
one way i would do the key inputs for pausing a game would be
if(keycode == KeyEvent.VK_P){
current_Level.isPaused = !current_Level.isPaused;
}
This is so you can toggle it on and off.
Just a little something i thought id share. If your happy with the way you do it. Its perfect.
I hate you for not thinking on that first ahahahahha
Joking, thanks mate! I will refactor to that