Returning to a paused screen

Is there a way to trigger something when a paused screen is unpaused? I want to make an effect that only appears when the paused screen first comes back into focus.

There are two ways (that I can think right now) :slight_smile:

Global variable, the intuitive way:
As you need to communicate something through scenes, is natural to use global variable.
For example, add a global variable named (for example) “just_unpaused”, then, you can use some events:

[code]// Pause scene
Conditions: (the one you like, at the beginning of the scene, just before return to the game, etc.)
Actions: Do = 1 to the global variable “just_unpaused”

// Game scene
Conditions: Global variable “just_unpaused” is = 1
Actions: Start here some actions when return from pause
Do = 0 to the global variable “just_unpaused”
[/code]
So the pause scene actives this global variable, then the game notice it, do something cool like a black transition, and deactivate the global variable, until the next pause.

Scene variable, easy:
The game scene knows when you paused it, so it could know when it’s just unpaused through a scene variable, with this:

[code]// Game scene
Conditions: Conditions to pause the scene (key “P” is pressed, etc.)
Actions: Do = 1 to the (scene) variable “just_unpaused”
Pause this scene and go to the scene “Pause scene”

Conditions: (scene) Variable “just_unpaused” is = 1
Actions: Start here some actions when return from pause
Do = 0 to the (scene) variable “just_unpaused”
[/code]
It works because you activate the variable and, immediately after that, you change the scene, so the game scene will be paused until you return, and only after that the game scene will notice that the variable was activated.
If this option doesn’t work, it could be that GD runs all the events before pause and change the scene, in this case you’ll have to put my second event above the first one :wink:

1 Like