This section contains all the steps you need to do in order to properly integrate your Game with GamePix SDK and Construct 2.
Before you start integrating the SDK methods inside your Game, here are a few things you need to check:
Download the plugin from here: https://integration.gamepix.com/sdk/plugins/c2/latest/gamepix-sdk.c2addon.
Important: You're going to add the actual SDK script after you export the game, in the index.html file (see step 4.2 of this guide).
Don't copy GamePix SDK methods code anywhere else in your game.
To install it drag and drop the file inside Construct 2 window. Once done you should see a confirm popup:

After that you have to insert the plugin in order to have it available:


Once done you can start implementing the methods of the GamePix SDK.
GamePix.loading
This method is automatically implemented when you import the plugin itself. To check that is working, when you preview the game, you have to see a badge on the top of the screen which notifies the current loading values.

GamePix.loaded
This event notifies that your game is ready to start but the code to make it really starts is inside the callback function loadedExecuted.
So here's a quick recap of how the flow should be:

As you can see you previously send an event via GamePixSDK.loaded and then you listen the response through function "loadedExecuted". Here's a quick screenshot of these two methods: When the game has completed to load all assets and is correctly initialized (e.g. previous state and/or global variables) trigger the GamePix.loaded but don't start the game.

When you receive the call from function named loadedExecuted you can actually starts the game.

GamePix.gameAction
Trigger GamePix.gameAction() upon the first user-input like a keystroke or mouseclick every time the user is beginning a gameplay. Don't call this event when you're in the menu.

When the event is fired while testing a badge on the top of the window will be showed to notify that event has been correctly implemented.

GamePix.gameStop
Trigger a gameplayStop() when the gameplay stops and is not interactive anymore.

When the event is fired while testing a badge on the top of the window will be showed to notify that event has been correctly implemented.

GamePix.updateScore
Call this function every time there's a score update inside the Game. The function accepts only numbers.


When the event is fired while testing a badge on the top of the window will be showed to notify that event has been correctly implemented.

GamePix.updateLevel
Call this function every time the user gets to a new level. The function accepts only numbers.
We're not showing screenshots of this function because the game we're using as test doesn't have levels. However the steps to use and check it are the same for updateScore but instead of score you need to pass the reached level.
GamePix.happyMoment
Send to the SDK if a particular "Happy Moment" just happened in your Game. It could be the unlocking of a special item, or triggering a cool event in the Game.

When the event is fired while testing a badge on the top of the window will be showed to notify that event has been correctly implemented.

GamePix.rewardAd
This function will ask SDK to show a Reward Ad which returns a call to function assignReward or denyReward if the reward has to be assigned or not.

Once added the action, don't forget to register the callback functions to assign or deny the reward as shown here:

Finally, to check that is working as expected, in your preview you'll see a dialog which asks to assign or not the reward.

GamePixSDK.lang
If your game has localized texts you can check the current language asking which value is:

possible values are those ones ['ar','zh','nl','en','fr','de','it','ja','ko','pl','pt','ru','es','tr']. If your games just use English you can skip this part.
To save and retrieve your game progress use the GamePix SDK LocalStorage functionalities.
GamePix.setItem
Use setItem to save a value inside GamePix.localStorage object. It accepts only string for key and value.

GamePixSDK.getItem
To retrieve a stored item you have to use GamePixSDK.getItem expression. NB this will return the string value "null" if the current searched item doesn't exist.

GamePixSDK.removeItem
Remove item is similar to setItem usage.
Once you're ready with the SDK implementation you're to do the following steps.
1. Export your game
2. Add inside the generated index.html file the SDK javascript tag as shown below:
<head> ... <script src="https://integration.gamepix.com/sdk/v3/gamepix.sdk.js"></script> ... </head>
3. Test the game inside GamePix Test Tool to see if all requirements are satisfied.
