Pause the Game

I wanna pause the scene and in that same scene I wanna open another sprite which will work as a window of paused game options. I have no Idea how will it work???

The problem is, if you pause the scene through time scale (set time scale = 0), then this pause window, including its buttons, will have time scale = 0 too, so their animations will not work. Other things will work I think, as render objects, check collisions, mouse over buttons, etc. .

Pausing the scene without time scale is very difficult, even more if you have the Physics behavior… believe me…

These are the reasons to use the “pause scene and go to Pause scene”, this Pause scene will have everything working, while the game is paused. Great option :slight_smile:

There is a branch on github featuring time scale for layers, but not sure when it will be availabe, or if it will be available at all. It would allow you to set the time scale of every game layer = 0, but set the scale of the pause layer = 1. Nice option, not officialy available :frowning:

is there an option in which the screenshot is taken and placed as background image in pause scene??? and can I give an option for saving the game in pause scene I mean how would it take the values from the previous scene?

EDIT: Please, read it first:
[url]Pause the Game]
The last option talks about a “time scale for layers” branch, now this branch is on master, so we will be able to test it officialy, I hope this feature do what I think it does.

In native you can take a screenshot if the “Primitive Drawing” extension is enabled, and then, in the pause scene, draw this picture over a background sprite (there is an action to do it in the Sprite section) :slight_smile:
I think this is not possible on web, probably with some JS + PIXI magic there is a way to do it.

This is a problem, a workaround could be to have the important things to save as global variables, objects data should be transferred to global variables to be able to save them. Sounds more like a problem than a workaround, I know :frowning:

Alternatively, you can just simply use a single variable to pause/unpause specific events like so:

Event: If Variable pause = 0 Sub-event: just put all the events here you want to be triggered only when the game is unpaused or stopped when it paused

And simply change the value of the variable when the pause key is pressed. To pause everything set the value of the variable to be 1 and to unpause set it to 0.
In case of physics objects, you need to set them to be static when paused and dynamic when unpaused.
This method is not so great with physics objects but for anything else should be good I think.

Yeah, this is the option I was thinking when I wrote:

Because even if you don’t have the Physics behavior, when you pause the game, you should save the current object forces (x and y), set the forces to 0, pause the animations, this for every “dynamic” object, pause timers, if you use the scene time or total game time in the game logic you will have to take the time paused into account :neutral_face:
Then you have to do the inverse proccess to unpause the game, using the saved force variables to set the old objects forces, play animations, timers, etc.
This proccess, if you have experience with GD, is not impossible at all, but anyway is not easy, not for everybody :wink:

I have an “old” example that I did just to know if this pause system is possible, finally it became a bit complex, is not commented and has no instructions (I didn’t think to share it):
PausablePlatformer.zip (31 KB)
*You can move the character with A and D
*Aim and shoot with the mouse, at any time, even with the ball on the air (a magic flying ball if you want) :smiley:
*The most important thing, pause with P
*This example is not intended to teach anything, you can end with a headache. But you can check the “Pause & Cameras” group, the first event is the one that pauses and unpause the game.

1 Like

Can I do this in C++ coding or something. does it sport C#, my friend knows C#. but what if I wanna stop animation too. when is new version of G Develop is coming out?

For the release you will have to wait a bit for sure, but you can test the feature in the nightlies build, it’s already out (the nightlies system works for Windows only at the moment). I’m testing it right now, and it works as I thought, so it will make your pause menu super easy :wink:
But it seems that the system is incompatible with the Physics behavior (as I thought), the physics engine doesn’t care about the object’s layer, everything works as a big world, ignoring the layer timescale :slight_smile: