Level: Beginner
Pausing
Pausing is such a common feature that we decided to include it in the Stencyl engine itself.
We opted for a simple approach to pausing: pause everything and you tell us what should remain active. This gives you full control, and at the same time, it minimizes the amount of work on your part.
Contents
-
Pausing
-
Opting Out (Staying Active)
-
Example: Simple Pause/Unpause
Pausing
Pausing freezes all “When Updating” events for Actors and all physics, unless you opt them out of pausing. In contrast, All “When Updating” events for Scenes are unaffected by pausing.
All Drawing Events still happen.
To pause and unpause the game, use these blocks under Scene > Game Flow.

Opting Out (Staying Active)
Often, you’ll want some Actors to remain active while the game is paused.
To opt an Actor out, flip to its Physics > Advanced page. Select “No” for this option.

Example: Simple Pause/Unpause
Notice that pausing preserves the full state of the actors. The ball will continue at the exact same trajectory as before.
This example’s simple and contains just 2 Events attached to the scene.
Event 1: Toggling Pause State
This part toggles between paused and unpaused when you press the spacebar.

Event 2: Tinting the Screen when Paused
This part darkens the screen a little when while the game’s paused by drawing a semi-transparent black rectangle on top of everything.

Summary
-
Pausing affects all actors by default.
-
Pausing stops updates to actors but does not affect scene behaviors/events.
-
Opt actors out to keep them active.
Challenge: Pause “Spell”
Who said that pausing had to be used just to pause the game? Let’s use pausing to create a Pause “Spell”, one that causes all enemies in a scene to freeze temporarily.
Create a game in which picking up a “timer” item will, for 30 seconds, cause all enemies to freeze up. Everything else will operate normally, including the player.
Last Updated: 2012-03-30 by Jon
8453 have read this article
Disclaimer: The Stencyl Team does not actively monitor comments on articles. If you're seeking help for your game,
please ask a question on the forums. Thanks!
Sign In to Comment