GameSnacks Developer SDK
Stay organized with collections
Save and categorize content based on your preferences.
The GameSnacks Developer SDK provides various features to games hosted on
GameSnacks.
You don't need to load any scripts; the SDK is automatically loaded for all
games hosted on GameSnacks.
GameSnacks interface
The main interface. An instance of this is available as the GameSnacks
property on window
.
Features marked as required must be integrated into your game following all
requirements listed within these features.
Properties
ad: Ad
Methods for displaying in-game advertising. Required
audio: Audio
Methods for controlling audio. Required
game: Game
Game lifecycle events and pause controls. Required
score: Score
Methods for updating the user's score. Required
storage: Storage
Methods for persisting game and save data. Required
Examples
// Register lifecycle event handlers.
GameSnacks.game.onPause(() => {
// Display pause screen.
engine.scene("pauseScreen").setVisible();
// Pause game loop.
engine.loop.sleep();
});
GameSnacks.game.onResume(...);
// Set up audio controls.
engine.sound.setMute(!GameSnacks.audio.isEnabled);
GameSnacks.audio.subscribe((isEnabled) => engine.sound.setMute(!isEnabled));
// Announce that the game is ready to be shown.
GameSnacks.game.firstFrameReady();
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-25 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-25 UTC."],[[["\u003cp\u003eThe GameSnacks Developer SDK automatically loads and provides essential features for games hosted on the platform.\u003c/p\u003e\n"],["\u003cp\u003eGames must integrate the required features: advertising, audio controls, game lifecycle management, score updates, and data storage.\u003c/p\u003e\n"],["\u003cp\u003eThe SDK offers a straightforward interface through the \u003ccode\u003eGameSnacks\u003c/code\u003e global object, granting access to functionalities like displaying ads or controlling the game's audio.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can utilize the provided methods and event handlers to seamlessly integrate their games with the GameSnacks platform.\u003c/p\u003e\n"]]],[],null,["# GameSnacks Developer SDK\n\nThe GameSnacks Developer SDK provides various features to games hosted on\nGameSnacks.\n\nYou don't need to load any scripts; the SDK is automatically loaded for all\ngames hosted on GameSnacks.\n\nGameSnacks interface\n--------------------\n\nThe main interface. An instance of this is available as the `GameSnacks`\nproperty on `window`.\n\nFeatures marked as **required** must be integrated into your game following all\nrequirements listed within these features.\n\n### Properties\n\n[`ad: Ad`](./ad) \n\nMethods for displaying in-game advertising. **Required**\n\n[`audio: Audio`](./audio) \n\nMethods for controlling audio. **Required**\n\n[`game: Game`](./game) \n\nGame lifecycle events and pause controls. **Required**\n\n[`score: Score`](./score) \n\nMethods for updating the user's score. **Required**\n\n[`storage: Storage`](./storage) \n\nMethods for persisting game and save data. **Required**\n\n### Examples\n\n // Register lifecycle event handlers.\n GameSnacks.game.onPause(() =\u003e {\n // Display pause screen.\n engine.scene(\"pauseScreen\").setVisible();\n // Pause game loop.\n engine.loop.sleep();\n });\n GameSnacks.game.onResume(...);\n\n // Set up audio controls.\n engine.sound.setMute(!GameSnacks.audio.isEnabled);\n GameSnacks.audio.subscribe((isEnabled) =\u003e engine.sound.setMute(!isEnabled));\n\n // Announce that the game is ready to be shown.\n GameSnacks.game.firstFrameReady();"]]