When I click esc or the menu object the game pauses, and then when I click exit the game changes the scene but resume does not work, the second click esc does not work either
Yeah, that sounds like a tricky issue. It might be that the game isn’t properly detecting the state change when resuming. Double-check if your pause logic is toggling correctly and if the resume function is actually unpausing or getting blocked by another condition. Also, debugging step by step can help clarify where it’s failing.
Where do you change the “pause active” boolean?
I have a strong suspicion that it causes the problem.
It could be that when you try to resume it really does resume BUT it pauses immediately again giving the illusion that the button doesn’t work.
If I am right, I think you can do a quick fix by using different buttons for opening and exiting menu. For example, use ESC to open menu, but use “Q” to close it and resume
Edit: I realized I’m probably wrong, since even clicking on “resume” doesn’t work. Sorry
Are the buttons in a separate layer?
Maybe you can try applying the time scale pause only on the game layer instead of the whole scene?
Also your variable “pause_active”, perhaps you might also want to check the action to switch it?
@MrMen maybe you can help?
I think it’s what @VALO was getting at - when you click on menu or press escape, you aren’t setting “pause_active
” to true. So the resume button nor the second escape will get actioned.
And remember to set “pause_active
” to false when play resumes.
@MrMen I tried different combinations and only one helped but only in 50%, when I click menu the game pauses, and I click resume the game unpauses, but esc does not work, when I press esc the game does not pause and the resume object appears without the other 2 objects. (I got rid of the esc option)
EDIT everywhere is false
And another problem: can there be errors during the “preview” of the game that do not occur when the game is exported for installation, e.g. on a PC?? The error is as follows: I press menu and the game pauses, but after 10 seconds of pause the object that the bullets were flying at suddenly explodes and there is an explosion sound (despite the pause) (the explosion graphic does not completely disappear) (the objects like mech1, air2 and bullets still do not move because there is a “pause”) WTF? I noticed something similar before I changed it so that the menu and resume objects pause and unpaused the game. Look , there is a pause :
Can you screen shot your attempt at doing I suggested? As it stands, that pause_active variable is redundant, it plays no useful role in the conditions.
The way you’re doing the pause system isn’t ideal. You should seriously consider using a FSM (finite state machine) and controlling the game flow and game state that way. You can combine that with a pause layer that you can hide or show for a more robust system. Here’s a very, very basic example of the FSM:
@MrMen I had to slightly modify your method because it didn’t work but it still doesn’t work 100% correctly now too, namely when I press esc the game doesn’t pause and 3 objects in this “resume” appear for less than a second. When I click on a menu object the game pauses but not as it should, i.e.: all units stop, projectiles fired should be paused but this doesn’t happen because they fly further and fly through the object (they don’t hit it), the “crossbow” from the mech falls slowly and doesn’t pause immediately, and generally it looks as if all forces were only just pausing after the work was done, except for the movement of units because they stop immediately, 3 objects in this resume appear, after clicking resume the game unpauses.
@MrMen grok helped me and it works, but unfortunately without the option to press ESC. Question: how to make the sound pause on all channels, e.g. 0-99??
I suspect the ESC key issue could be because the escape released condition is true for the entire frame.
So when it’s true during play it gets actioned, the pause screen is displayed and the game state is set to “Pause”.
However, it will still be true when the pause screen is displayed, and so the game state is set back to “Play”.
Two ways I can think of to get around this:
-
Remove the escape key release conditions from the play and pause states, and have an independent event like:
-
Or, add 2 more game states - “EscapePlay” and “EscapePause”. When escape is pressed during play, set game state to “EscapePlay”, and for escape in Pause, set to “EscapePause”. Put these two states into conditions at the very end of the event sheet, and they have just one action to set the game state to “Pause” or “Play”:
Just one thing about stopping volume on all canals : simply set volume to 0 for all sounds or Musics.
Perhaps this can correspond to you
A+
Xierra54
This won’t stop the music, it just turns it silent.
To stop it on all channels, you’ll need to have a repeat event and a variable for teh channel number that gets incremented each loop.
Yes of course but perhaps this simple idea can correspond to his needs
A+
It turned out that my method did not work