Page Summary
-
The
onPausemethod subscribes to pause events in your game. -
When the
onPausecallback is triggered, your game must completely pause all execution, including the game loop, sounds, music, and rendering. -
You should not use the Page Visibility API or similar APIs for handling game pausing; only use the GameSnacks SDK methods.
-
It is recommended to save user progress when the game is paused via the
onPausecallback.
onPause(callback: () => void): void;
Subscribes to pause events.
Examples
GameSnacks.game.onPause(() => {
// Display pause screen.
engine.scene("pauseScreen").setVisible();
engine.loop.sleep();
});
Requirements
- Your game must pause all execution when
callbackis called and must resume execution only when thecallbackforonResumeis called. This applies to all game behaviors including: the game loop, sounds, music, interactions, network calls, and rendering. - Your game must not use the Page Visibility API or similar APIs and must only use these GameSnacks SDK methods.
- Your game should save user progress when
callbackis called. - Your game must clearly communicate to the user if it's paused.