GameSnacks 开发者 SDK
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
GameSnacks 开发者 SDK 可为托管在 GameSnacks 上的游戏提供各种功能。
您无需加载任何脚本;对于托管在 GameSnacks 上的所有游戏,此 SDK 都会自动加载。
GameSnacks 接口
这是主要接口。该接口的实例可在 window
中作为 GameSnacks
属性使用。
标为必需的功能必须按照这些功能中列出的全部要求集成到您的游戏中。
属性
ad: Ad
展示游戏内广告的方法。必需
audio: Audio
控制音频的方法。必需
game: Game
游戏生命周期事件和暂停控件。必需
score: Score
更新用户得分的方法。必需
storage: Storage
保留游戏和保存数据的方法。必需
示例
// 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();
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2024-12-24。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["没有我需要的信息","missingTheInformationINeed","thumb-down"],["太复杂/步骤太多","tooComplicatedTooManySteps","thumb-down"],["内容需要更新","outOfDate","thumb-down"],["翻译问题","translationIssue","thumb-down"],["示例/代码问题","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2024-12-24。"],[[["The GameSnacks Developer SDK automatically loads and provides essential features for games hosted on the platform."],["Games must integrate the required features: advertising, audio controls, game lifecycle management, score updates, and data storage."],["The SDK offers a straightforward interface through the `GameSnacks` global object, granting access to functionalities like displaying ads or controlling the game's audio."],["Developers can utilize the provided methods and event handlers to seamlessly integrate their games with the GameSnacks platform."]]],[]]