AI-generated Key Takeaways
-
Subscribes to pause events, allowing developers to execute specific actions when a pause occurs, such as displaying a pause screen or saving game progress.
-
Games must pause all game execution, including sounds, music, and network calls, when the pause callback is triggered and only resume upon receiving the resume callback.
-
Games must rely exclusively on GameSnacks SDK's pause and resume methods for managing the pause state and avoid using alternative APIs like the Page Visibility API.
-
It's recommended to save the user's progress and provide a clear visual indication within the game to signal the paused state.
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
callback
is called and must resume execution only when thecallback
foronResume
is 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
callback
is called. - Your game must clearly communicate to the user if it's paused.