PauseThisScreen
Introduction
PauseThisScreen can be used to implement pausing. In many cases, this function will effectively provide pause implementation for games.
Example Usage - Pausing With the Keyboard
The following code shows how to pause and unpause the screen using a gamepad's Start button.
When the game is paused, the Sprite automatically stops rotating and resumes when the game is unpaused.
Applying Movement After Pause
When a Screen is paused, the underlying engine logic does not stop. Rather, the velocity of all objects is stopped and stored in instructions. When the screen is unpaused, all velocity values are re-applied. This means that if a velocity is changed after a screen is paused, the object which has been given velocity (or acceleration) will continue to operate while everything else remains paused. Furthermore, whenever a Screen is paused, its CustomActivity continues to be called every frame even while paused. Therefore, you can perform additional logic after a pause.
Example - Applying Movement After Pause
The following code assumes an Entity named Ball. Clicking the cursor creates a new Ball which falls. Pressing the Space toggles pause. Notice that pausing the game will pause all existing entities, but new entities created after a pause will fall normally.
Example - Playing Gum Animations After Pausing
Gum animations internally create Tweeners on the TweenerManager. When the Screen is paused, all Tweeners are paused. If your game includes a Gum object which animates when the game is paused (such as a menu sliding on the screen), you can play the animation after the PauseThisScreen call and the animation will still play normally.
The following code animates a button on-screen after the game is paused.