Page Summary
-
The GameSnacks Developer SDK offers features for games hosted on GameSnacks and is automatically loaded.
-
Features marked as required within the SDK must be integrated into your game.
-
The main SDK interface is available as
window.GameSnacksand includes properties for managing ads, audio, game lifecycle, score, and storage. -
The SDK provides methods for handling game lifecycle events, controlling audio, and notifying when the game is ready.
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();