Cross Platform – Game Template


Live Demo

See the template in action.

[appbox googleplay com.matchtrhee.shatter]

[appbox appstore 1111204649]

We use the same template in our game Match3. There you can see all functions in action!


Thank you for checking out our documentation about our Cross-Platform Game Template (CPPT). Here you’ll find all what you need to start building your awesome game using our template.

Updates & Reviews

Please always check if you’re using the latest version of our template. Just check regulary your download area on scirra.

  Scirra - My Downloads

If you are satisfied with our item, please rate it 5-stars on scirra. This helps us a lot and encourage us to publish further updates with more cool stuff included.

If you want to get notifed about updates, feel free to join us on Twitter or Facebook. Moreover you can subscribe to our newsletter.

  Twitter   Facebook


Ready for Android and iOS
This project combines both, Android and iOS functions. So you can build your game in one project and compile it to two platforms without making any changes to it!
3 years expierences with C2
This project includes knowledge of 3 years experiences of working with Construct 2 and CocoonJS (and now CocoonIO). Therefor this template shouldn't be used from bloody beginners, expected you are willing to learn it from the hard way 😛
AdMob and Chartboost Ads
Monetize your game directly with AdMob Ads (Banner and Interstitial) and Chartboost (Rewarded Videos and Interstitial Ads). All what you need is included in this project and ready to use on Android and iOS!
Google Analytics
Track your user interactions with Google Analytics. The game is ready for it!
This template is ready for localisation (autmatically detects the device language, and if it's supported it will translate all objects. Otherwise it will use the defined fallback language).
InApp Purchase
Allow your player to purchase coins and a Remove Ad perk. The function for this is completely included in this template and works for Android and iOS.
All buyers will get support! All functions are debugged and tested (this template is included in our game Match3) and will be improved and extended with each version.


This template is exclusive for CocoonIO and will not work with Intel XDK! You can learn more about here.


This template needs some plugins to work (and in order to open the file). Most plugins are available for free, but it also uses Cranberrygame’s Cordova Plugins. So please make sure that you have purchased his Cordova Plugin package available on Scirra.

Please install all listed plugins & behaviors befor you open the project file with construct 2.

Used Plugins

(Free) Cocoon Attomic Plugins

This templates uses Ludei’s free Atomic Plugins for Construct 2.

  • CocoonCanvasPlus
  • CocoonInApps (works for both, Android and iOS)
  • CocoonGameCenter (Leaderboard for iOS only)
  • CocoonGooglePlayGames (Leaderboard for Android only)

You can download all plugins here.


Cocoon Construct 2 Plugins 8 MB 4060 downloads

Download the Cocoon Plugins for Construct 2 now! The download link fetches the latest...

If you need a guide showing you how to install those plugins, please see here.

  How to install Cocoon Plugins
Just to be sure...

You must install the corresponding plugins in CocoonIO! Otherwise your game results in a black screen. Please see below!

(Free) TimeAwayL

The template uses Rex’s awesome TimeAwayL plugin for the Reward System. You can download it for free on his website.

  TimeAwayL by Rex

(Free) SpriteFont+

The template uses thechriskent‘s awesome TimeAwayL plugin for the Reward System. You can download it for free on his website.

  SpriteFont+ by thechriskent

(Paid) Cranberrygame’s Cordova Package

This template uses following plugins included in Cranberrygame’s Cordova Package.

  • Cordova Chartboost
  • Cordova Google Analytics
  • Cordova Dialogs

If you don’t own this package, please purchase it from here. It includes so many helpful plugins.


Cranberrygame - Cordova Plugins 150 MB 3094 downloads

Download the awesome Cordova Plugin Package provided by Cranberrygame. The package...


Just to be sure...

You must install the corresponding plugins in CocoonIO! Otherwise your game results in a black screen. Please see below!

Install corresponding plugins in CocoonIO

Please add following plugins to your CocoonIO project:

Cocoon Plugins

  • AdMob native Ads for Android
  • AdMob native Ads for iOS
  • Google Play Games Social API (Add your APP ID to it)
  • Game Center Social API
  • In-App Purchases for Google Play
  • In-App Purchases for iOS App Store

Core Plugins

  • Inappbrowser
  • Dialogs

Custom Plugins

  • Git-Repo:
  • Git-Repo:

Used Behaviors

(Free) LiteTween

This templates uses lunarray‘s  free LiteTween behavior for Construct 2. You can download it here.

  LiteTween by lunarray

Event Sheets

The project is sorted in its functions. So there is an event sheet for each function included in the project.

  • es_inapp (Handles the store functions)
  • es_ads (Handles the AdMob Ad functions)
  • es_analytics (Handles the Google Analytics functions)
  • es_leaderboard (Handles the Leaderboard functions, Game Center and Google Play Games)

Then there are the layout event sheets.

  • es_loader (for the loader)
  • es_menu (for the menu)
  • es_store (for the store)
  • es_earncoins (for the earn coins screen using Chartboost)
  • es_settings (for the settings screen)
  • es_help (for the help screen)
  • es_game (for YOUR Game)


The es_game Event Sheet

This is the place were you should code your game. There are a few functions included to show you a possible way to do it. But basically it’s completely up to you how you build your game in there. If you need something from other event sheets, like showing an Interstitial Ad, you just can included the event sheed es_ads into the es_game event sheet and call the function for showing an interstitial ad. You’ll find an overview of all functions in the “Functions” section of this documentation.

The es_global Event Sheet

This event sheet should be included in each other Layout event sheet, due to the fact it handles the LocalStorage and UI functions.

Clean and well commented!

Our project is well structured and well commented.

Seperated in Groups


Well commented

To help you understanding the code better, I have added comments to it.



You also get the Localisation system stand-alone!

  Game Template 13 - Localisation

This template includes an automtic function for localisation. For this it uses the “languages.json” file included in the Construct 2 project. In order to alter the file, just perform a double click on it.


The languages.json file

The json-file is using keys to identify the language string.


On the first game start this json file will be imported to the “Languages” Dictionary in Construct 2 via AJAX. After that all strings are available in the game and you can access the language by its key.


For this use following format.

[js]/* language = is the variable where the language code will be stored
* _dialog_rateapp_headline = the key from the json file (without de,en, and so on!)
languages.Get(language & “_dialog_rateapp_headline”)[/js]

This will fetch the text assoziated with the key. But see more under “Localize”



Each SpriteFont+ object is included in the “SpriteFontPlus” family. Therefor each SpriteFont+ object has a boolean “IsLocalised” and a string instance variable called “LanguageKey”. Those variables will be used to speed up the the translation and to reduce the needed code for it.

How to localize it

  • 1) Set “IsLocalised” to true
  • 2) Add the language key (from the json file) in following format

[js]// if the key is “de_howto_game_1” add it like:


  • 3) That’s it

Now it automatically fetches the text from the corresponding key on start of each layout. Just make sure, if you have added additional SpriteFont+ objects, to include them in the “SpriteFontPlus” family.



If you have any sprite objects with a text on it, please duplicate the animation for each language and name it to the language code.


For example if you want to support german, english and french  add following animations in lowercase!

  • de
  • en
  • fr

Then add the sprite object to the “Sprites” family. This will add the boolean “IsLocalised” to each included object. Set it to true if the sprite has a text on it and it has the needed language animation. Otherwise let it on false.


The game automatically sets the corresponding animation.


For all other objects, like the Cordova Dialog object, you just can call the language string by following expression.

[js]/* language = is the variable where the language code will be stored
* _dialog_rateapp_headline = the key from the json file (without de,en, and so on!)
languages.Get(language & “_dialog_rateapp_headline”)[/js]



Add a new language

If you want to add a new language, just copy all keys in the language.json file and replace the language code with your language. For example if you want to add french.

[js]”en_back_content”: “You are about to go back to the menu screen. Proceed?”,
“de_back_content”: “Sie sind dabei in das Menü zurückzukehren. Fortfahren?”,
“fr_back_content”: “YOUR TEXT IN FRENCH”,[/js]


Then save your file and open the “es_language” event sheet (located in “Globals”). There you’ll find a variable called “languages”. This variable represent all available languages. If the player has an unsupported language, the system automatically uses the fallback language (mostly english, but it depends on you).


So add fr to this variable.


Then change the “languages_count” variable to 3 (three supported languages).


Make sure that if you add a new language, that you have added all keys in the language.json file and added all new animations to sprite objects for the new translation! If a key cannot be found in the json file, it sets the text to “0”.


Here you find a list of all available functions which you can use for your game.


If you want to use InApp functions outside of the es_inapp event sheet, just include this event sheet in the one you want to use the InApp functions.


This function basically gets called on the first start of the game and fetches all listed products from the store. This function should be used only in the es_inapp event sheet.

Make sure that you adjust the list of product ID’s getting fetched from the store. If you try to fetch an undefined product, the fetch process will fail.

Return value: none



This function will create a local product list on the device. This is needed in order to access the localized price and name later.

Do not alter this function.

Return value: none



With this function you can purchase an item. In order to do that you need to pass two parameters.

  • Function.Param(0) = The Product ID of your Item (string)
  • Function.Param(1) = Amount (integer)

Use the “Product_ID” variables in the header for the Function.Param(0). So it automatically triggers the matching “On purchase succeeded”.

In order to use this function you must include the es_inapp event sheet in the event sheet where you want to use it.


Return value: none



With this function you can consume an item. In order to do that you need to pass two parameters.

  • Function.Param(0) = The Product ID of your Item (string)
  • Function.Param(1) = Amount (integer)

In order to use this function you must include the es_inapp event sheet in the event sheet where you want to use it.

Return value: none


Ads (AdMob)

If you want to use AdMob Ad functions outside of the es_ads event sheet, just include this event sheet in the one you want to use the AdMob Ad functions.


This function can be used to show an Interstital Ad. This functon also includes a counter. So if you call this function, the ad_counter will be reduced by 1.

  • If this ad_counter = 1, an Interstital Ad will be preloaded
  • If this ad_counter = 0, an Interstital Ad will be shown

The best usage for this function is to call it on each game over. Then, depending on the value of the ad_counter_fallback (for instance 5) value, it will show an Interstital Ad after each fifth GameOver.

Return value: none

There is no function for the banner ad. It will be shown on the specified layouts in the es_ads event sheet.

Google Analytics

If you want to use Google Analytics functions outside of the es_analytics event sheet, just include this event sheet in the one you want to use the Google Analytics functions.


This function will track the passed screen.

  • Funtion.Param(0) = Screen name (string)

This function is already included in the es_global event sheet and it tracks all layouts automatically. So there is no need to do this on your own.


Return value: none



This function will track an event for a category.

  • Function.Param(0) = category (string)
  • Function.Param(1) = event (string)

Call this function whenever you want to track a special event, for instance a button click or something in that way. You’ll find a lot of examples in the included event sheets.


Return value: none


If you want to use global functions outside of the es_global event sheet, just include this event sheet in the one you want to use the global functions.


This function updates the SpriteFont+ Object in the UI to the current value of the “coins” variable. Call this function whenever the coins variable has changed its value.

Return value: none



This function updates the SpirteFont+ Object in the UI to the current HighScore and Score currently stored in the HighScore and CurScore variable. Call this function whenever the HighScore or/and CurScore variable has changed.

Return value: none



This function calculates the amount of coins which a player wins after he / she has lost the game. You can alter this function to fit your needs.

Return value: AwardedCoins



This function calls a login to the leaderboard. It picks automatically the right one, depending on the device platform (OS).

Return value: none



This function submitts the passed achievement ID to the corresponding leaderboard. Due to the diffrent ID’s on iOS and Android this function must be called depending on its platform.

  • Function.Param(0) = Achievement ID (string)

In order to do this, you can submit the achievement like this.


You should pass the variable for it.


Return value: none




This template comes with a completely working InApp function allowing your player to purchase

  • a “Remove Ad” Perk
  • four diffrent coin packages

In order to use this function in your game you musst add your Product ID’s in the header of the “es_inapp” event sheet.



Please use the same Product ID’s on iTunes and on Google Play. Otherwise you have to modify the game code.

The easiest way is to copy the ID’s from the template and use them while creating your InApp products in iTunes / Google Play.

Google Play

Here you can add all items as “Managed”. The coins package will be automatically consumed after the had been purchased. Otherwise it wouldn’t be possible to purchase it again.


If you need help with creating an InApp Product in Google Play, please visit this guide.

  Google Play - Add InApp Product


However in iTunes you have to create a “Consumable” Item for the coin packages and a “non-consumable” item for the Remove Ads Perk.


If you need help with creating an InApp Product in iTunes, please visit this guide.

  iTunes - Add InApp Product


In order to use the Interstital Ads and the Banner Ad in your game, you need to add your AdMob ID’s to the CocoonAds Plugin (located in Construct -> Plugins folder). You can create those ID’s in your AdMob Dashboard.

  AdMob - Dashboard
Please note...

In order to test the ad functions, you can insert the Test ID’s. Those ID’s can be find in the “es_ads” event sheet header.


In order to use the Rewarded Video Ads in your game, you need to add your

  • Android App ID
  • Android App Signature
  • iOS App ID
  • iOS App Signature

to the Cordova Chartboost Plugin (located in Construct -> Plugins folder). You can create those ID’s in your Chartboost Dashboard.

  Chartboost - Dashboard


In order to use the Google Analytic Tracking functions, you have to add your Google Analytics ID to the Cordova Analytics Plugin (located in Construct -> Plugins folder). You can create one in your Google Analytics Dashboard.

  Google Analytics - Dashboard

You can compile this project to Android and iOS using Ludei’s CocoonIO.


Please see our guides below.

  How to build with CocoonIO and Construct 2

This guide will show you how to export, configure and compile your game using Ludei’s CocoonIO and Scirra’s Construct 2.

Platform specific

  Publish to Google Play and/or    Publish to iTunes

Those guides above will show you how to publish your games on Android or/and on iOS.

Updated on May 6, 2018

Was this article helpful?

Related Articles

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.