Construct 3 SDK
All the functionality of our SDK is showcased in this demo project. To avoid weird browser behavior, right-click the link, and select Save link as
.
Requirements
When integrating the CrazyGames SDK, make sure to follow our requirements. They will help you use the SDK in the best way possible and guide you in terms of technical, gameplay, ads and account integration requirements.
Installation
You will need to create a separate layout for loading and initializing the SDK. Our demo project contains an example layout called CrazySDKLoadingDemo
. That layout should contain a System > On start of layout
script with these contents:
const nextLayoutName = "CrazySDKDemo"; // don't forget to set the name of the next layout that should be loaded after initialization
const sdkElem = document.createElement("script");
sdkElem.type = "text/javascript";
sdkElem.src = "https://sdk.crazygames.com/Construct3CrazySDK-v3.js";
document.body.appendChild(sdkElem);
sdkElem.onload = function () {
window.ConstructCrazySDK.init()
.then(() => {
runtime.goToLayout(nextLayoutName);
})
.catch((e) => console.log("Failed to init CrazySDK", e));
};
sdkElem.onerror = function () {
console.error("Failed to load Construct3CrazySDK script.");
};
The script will load our SDK, initialize it, and continue to nextLayoutName
.
Warning
The CrazyGames SDK is not working with Construct "Worker mode". "Worker mode" can be disabled by selecting your project in the "Project" panel, going to "Advanced", and setting "Use worker" to "No"
Development
When using our SDK with Construct preview, you will see fake ads. To see the real behavior of your game like it would be on Crazygames, use our QATool with the HTML5 engine.
Modules
The SDK has the following modules:
ad
- display video ads, detect adblockersbanner
- display bannersgame
- various game eventsuser
- for interacting with the currently logged in userdata
- for storing user data that persists across devices
Each one of these modules can be accessed as follows:
window.CrazyGames.SDK.[moduleName]
, for example, window.CrazyGames.SDK.ad
.
About using the SDK
The SDK functionality is implemented in JavaScript, so to call various features from the SDK, you will need to add scripts to your event sheets. When right-clicking on your events, you will get an "Add script" option, which will add a small text editor where you can write the code.