How to detect when the game is paused by code

Is there any way to know by code when the game is paused?

what do you mean paused, you want to create a pause menu in the game and don’t know how to detect it?

detect it by code

your own made pause menu?

If you want to know whether the timeline is moving or not, you can use

project.timeline._playing

It should be equal to true if the timeline is playing, and false if the timeline was paused by “stop()”

1 Like

assuming you made a pause button, you now need a boolean (true/false). make a variable called paused and set it to false. when the button is pressed, toggle the boolean by setting it to the opposite (for example, paused = !paused;).

the game should only run if paused is false. you can use an if statement to check for this.

note: this may not work depending the game’s complexity and how well you coded your game. if you code your game well and use object-oriented programming, it will be a lot easier. if you leave a lot of bits of code in many clips and scripts, it will probably take more than just checking a boolean.

1 Like