GamePix Cocos

1. Installation

1. Please install gamepix-sdk extension from the Cocos Store.

Use "GamePix" to search the extension.

Search the extension

2. Add the plugin to project using "Add to project" button.

Add to project

GamePix sdk is provided by function gpx(), you can import it from gamepix module:

Code
import { gpx } from "db://gamepix-sdk/gamepix";

gpx().<funtion name>();

2. Usage

You can access all SDK using only gpx() function.

3. Interstitial AD

Let's declare function that handles key events and run Interstitial Ad.

Code
import { gpx } from "db://gamepix-sdk/gamepix";

// ...
input.on(Input.EventType.KEY_UP, () => {
    gpx().interstitialAd().then((res) => {
        log("intestitialAd was shown?", res.success);
    });
}, this);

4. Rewarded AD

Let's declare function that handles key events and run Rewarded Ad.

Code
import { gpx } from "db://gamepix-sdk/gamepix";

// ...
input.on(Input.EventType.KEY_UP, () => {
    gpx().rewardAd().then((res) => {
        log("rewardedAd was shown?", res.success);
    });
}, this);

5. Other methods

  • gpx().lang() - gets the current preferred language by the player
  • gpx().langSync() - same as lang(), but will return null if SDK is not yet initialized
  • gpx().updateScore(score) - should be called immediately every time the current score is updated
  • gpx().updateLevel(level) - should be called to send the score after the player passed the level
  • gpx().happyMoment() - should be called when Happy Moment just happened
  • gpx().setItem(key, value) - persistently stores the value. The value must be a string
  • gpx().getItem(key) - read value from storage
  • gpx().getItemSync(key) - same as getItem(), but will return null if SDK is not yet initialized