-
Notifications
You must be signed in to change notification settings - Fork 0
Store API Integration
You can integrate the GameDistribution Store API in your Cocos Creator HTML5 projects using JavaScript. This enables access to virtual items, currencies, cart actions, and inventory features provided by the GameDistribution Store system.
Make sure your Cocos Creator project is exported as an HTML5 Web project. Then include the GameDistribution SDK in your HTML template.
In your index.html or template:
<script type="text/javascript">
window["GD_OPTIONS"] = {
gameId: "your-game-id",
onEvent: function(event) {
console.log("GD Event:", event);
}
};
</script>
<script src="https://html5.api.gamedistribution.com/main.js"></script>You can call Store API methods from your game's script files.
const items = await gdsdk.executeStoreAction({ action: "api.items" });
console.log("Available store items:", items);await gdsdk.executeStoreAction({
action: "api.buyProduct",
payload: { sku: "ss-enhance-shield-5", quantity: 1 }
});You can call UI-related store actions like:
gdsdk.executeStoreAction({ action: "ui.open" });gdsdk.executeStoreAction({ action: "ui.close" });These can be triggered from in-game buttons, events, or lifecycle hooks.
Please check back for screenshot references for integrating buttons or calling actions from components in Cocos Creator Editor.
π GameDistribution HTML5 SDK - Store API Usage
If you need an example project for Cocos, please contact the GameDistribution developer team.