Looking for the old Construct 3 SDK? You can find it here.
All the functionality of our SDK is showcased in this demo project. We recommend that you also check it beside the docs.
In your Main script, add the following lines at the bottom.
If you don't have yet a Main script, right-click on the "Scripts" folder in the "Project" view, and create a new script. In the "Properties" panel, ensure the script purpose is set to "Main script".
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"
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.
About using the SDK
Guidelines for Advertisements
Please be sure to read our advertisement guidelines, since your game will be rejected without any feedback if it doesn't follow them.
Ad breaks can be requested using the
requestAd() function. You’ll have to make sure to pause your game before playing the ad by setting the time scale to 0 (System action). Be sure there isn't any audio playing also while the ad is displayed. Then use the
Wait for previous action system event and resume the game when the ad finishes by setting the time scale back to 1. Your event sheet should look like this:
We support two different types of ad breaks: midgame and rewarded. Midgame advertisements can happen when a user dies, a level has been completed, etc.
Rewarded advertisements can be requested by the user in exchange for a reward (An additional life, a retry when the user died, a bonus starting item, extra starting health, etc.).
Rewarded ads should be shown when users explicitly consent to watch an advertisement.
requestAd() has an argument that indicates the ad type. You can request both types as follows:
We detect whether the user has installed an adblock tool. We pass this information to the developer through the
hasAdBlock() function. That function returns a boolean that you can assign to a global variable (make sure that your variable type is also boolean):
We require games to function even when the user has an adblock. The detection is not foolproof, and it would be very frustrating for a user not running any adblock to get a non-functional game. You can block extra content, such as custom skins, or some levels, to motivate the user to turn off their adblock. Also, keep in mind that turning off the adblock usually requires a page refresh. Make sure that the progress is saved, or the user may just decide to stop playing your game.
Our SDK allows you to display ad banners directly into your game. Here are the available sizes:
To request ad banners you can call the
requestBanners() function like in the following code:
The method takes a single argument which is an array of banners, so you can request also 1 banner for example. When calling the method, all the previous banners will be removed. If you need to refresh the banners, call the method again with the same banner list.
You have to specify all 5 parameters for each banner:
id:a unique id to identify the banner
x:the horizontal position for the banner, from the bottom left screen corner
y:vertical position of the banner, from the bottom left screen corner
width:the banner width
height:the banner height
The banners have some limitations:
- You can display up to two banners of each size at the same time at once (ex: 728x90 and 300x250, two 300x250, ...). We ask you to make a reasonable usage of banners in order not to deteriorate the player’s experience.
- You can refresh a banner simply by re-executing the banner request. You'll have to wait a minimum of 60 seconds before refreshing a banner. You can do a maximum of 60 refreshes per banner for a game session.
- The banner has to be fully inside the game window and not overlap with any UI element. If the banner is outside the window, even by 1 pixel, it will not be displayed.
If you need to hide all the displayed banners, call this method:
happytime() method can be called on various player achievements (beating a boss, reaching a highscore, etc.). It makes the website celebrate (for example by launching some confetti). There is no need to call this when a level is completed, or an item is obtained.
We provide functions that enable us to track when and how users are playing your games. These can be used to ensure our site does not perform resource-intensive actions while a user is playing.
gameplayStart() function has to be called whenever the player starts playing or resumes playing after a break (menu/loading/achievement screen, game paused, etc.).
gameplayStop() function has to be called on every game break (entering a menu, switching levels, pausing the game, ...) don't forget to call
gameplayStart() when the gameplay resumes.
This feature lets you share the Crazygames version of your game with the players and invite them to join a multiplayer game. You can call
inviteLink with a map of parameters that correspond to your game or game room.
You can check for invite parameters with the
getInviteParameter() function as follows.
Don't forget to check the demo project also, which showcases all the functionality of the SDK.