CoolGames SDK integration
We’re very excited to have your game on our network of sites! This tutorial will guide you through the steps to add and initialize the CoolGames SDK in your HTML5 game. Integrating the CoolGames SDK is a requirement before your game can be distributed on the CoolGames network.
If you have any questions about these requirements, please feel free to email your licensing manager, and if you have technical questions about implementation, e-mail dev-support@coolgames.com.
For design and technical requirements, please refer to CoolGames Design & Technical Guideline. We look forward to publishing your game!
1) SDK Implementation
The first step is to implement the SDK in your game.
To do so, add a publisher.js file to your game and insert the code below which will load and initialize the SDK.
This is located on our game servers and will work correctly once we upload your game.
Include the SDK
Load the publisher.js file in the index.html within the HEAD tags.
<script src=”publisher.js”></script>
Device Orientation
The Booster.Init function accepts an object with orientation parameter which can be “portrait”, “landscape” or “both”.
Please set the value to your game’s desired orientation.
Ad Banner
The SDK will add an ad banner on the bottom of your game. (see new Booster.AdBanner({}) inside publisher.js)
The height of the banner is 50 or 60 pixels, make sure the banner won’t block any important content.
Alternatively you could shrink your canvas by 60 pixels and move it up to leave empty space at the bottom for the banner.
Pause handlers
In the code above there are two empty functions. (pauseGame and resumegame)
Implement these functions so that the game is paused and audio is muted.
Game loading
Your game should be started after the SDK has been initialized.
The SDK will call the Booster.onSplashFinishedEvent function when it’s ready, this is the place where you should start your game.
2) Adding Ads to Your game
The most effective spot to place an ad call is at the end of each level (for either a success or a failure) as well when restarting or quitting a level. This prevents advertisements from interrupting the player in the middle of the game.
Regardless of how often you call the Advertising function, there is a minimum 1 minute cool-down between ads to prevent the player from being spammed.
To trigger an advertisement use the adSense.showAdvertising({ callback: function }); function and provide a callback.
Rewarded Ads
When the rewarded ads should be shown, the following call must be made:
window.Booster.RewardedVideo.play(successCallback: function, context: object, failCallback: function);
3) Community features
After level completion the score should be submitted for community features such as highscores.
Before submitting the score make sure the game is paused and resume the game in the callback.
There are two different score functions that can be used.
Choose the one that is most appropriate for your game.
submitScore
community.submitScore({ score: number, callback: function });
submitSessionScore
Use this if your game is re-playable or has levels that are re-playable.
Each week these scores are reset so users can try and beat the highscore.
community.submitSessionScore({ score: number, level: number, callback: function });
4) Analytics
The CoolGames SDK includes support for event tracking to see how players progress through a game.
CoolGames uses these events, combined with our other analytics tools, to track game performance across the global network.
The CoolGames SDK includes three built-in events you should use at the appropriate locations in your game’s code.
- analytics.level(level: number); – Call this when the player completed a level
- analytics.levelFailed(level: number); – Call then when the player failed a level
- analytics.score(score: number); – Call this when the player completed a level.
Example
There is an example game with our SDK integrated.
We have shown publisher.js file contents above, now let’s see what the index.html file and game code can look like:
Game Delivery
Once you’ve integrated the CoolGames SDK and implemented the relevant and required functionality, it’s time for you to prepare your complete game package for final submission.
You should submit your game as a download link (via dropbox, google drive, or any other cloud service) to your Licensing Manager.
Need Help?
If you have any questions about these requirements, please feel free to e-mail your licensing manager, and if you have technical questions about implementation, e-mail dev-support@coolgames.com.