Game onPause method
Stay organized with collections
Save and categorize content based on your preferences.
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 the callback
for onResume
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.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-09-03 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-09-03 UTC."],[[["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."]]],[]]