GamePix Game Maker Plugin

1. Installation

  • Please download the plugin and extract it somewhere.
  • Open your GameMaker project.
  • In Asset Browser right click on Extensions and create blank extension called GamePix.
  • Create an empty plugin
  • Open extension folder in file explorer (you can use Show In File Manager button in popup menu).
  • Copy contents of GamePix plugin archive into that directory, if you did it right GameMaker will ask you to reload plugin, please do it.
  • When plugin is reloaded you should see GamePix.js in extension files and you can use GamePix sdk as explained in below.
  • GamePix plugin is ready to use
  • NOTE: Very rarely you need to restart GameMaker to apply changes.

2. Usage

GamePix sdk is provided by functions with gpx_ prefix. The GameMaker studio should show short help information about each gpx_ function.

You can use gpx_ functions directly in your gml scripts. Most functions are async and you need to provide callback function as last argument, e.g:

Code
callback_fn = function(...) {
    ...
}

gpx_fn(callback_fn)

IMPORTANT: Do not use *var* when declaring callback. The callback must be defined in global scope (without var).

3. Get the prefered language

There are two options to get players preffered language. One is to call gpx_langSync which return language code immediately, but if GamePix SDK is not initialized then this function return empty string.

More robust way to get language is to use async variant:

Code
on_gpx_lang = function(lang) {
  // lang is a code of language, like en, it, ru, etc.
  show_message(lang)
}
gpx_lang(on_gpx_lang)

4. Interstitial AD

To show fullscreen interstitial AD please use following snippet:

Code
callback = function(success) {
    // CODE TO RESUME GAME
    show_message(success)
}
// CODE TO PAUSE GAME
gpx_interstitialAd(callback)

* success - can be 0 or 1, 1 means ad successfuly showed

IMPORTANT: It's very important to pause your game (including music) before showing the AD, so please implement code to pause/resume game properly. See example below.

5. Rewarded AD

To show fullscreen rewarded AD please use following snippet:

Code
callback = function(success) {
    // CODE TO RESUME GAME
    if (success == 1) {
        show_message("There is your reward :)")
    } else {
        show_message("Can't give reward :(")
    }
}
// CODE TO PAUSE GAME
gpx_rewardAd(callback)

* success - can be 0 or 1, 1 means ad successfuly showedand you can provide reward to player

IMPORTANT: It's very important to pause your game (including music) before showing the AD, so please implement code to pause/resume game properly.You can do this with following code:

Code
callback = function(success) {
    audio_master_gain(1)
    instance_activate_all()
    //...
}

audio_master_gain(0)
instance_deactivate_all(false)
gpx_rewardAd(callback)

6. Other methods

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, callback) - Read value from storage.

gpx_getItem(key) - Same as getItem, but will return null if SDK is not yet initalized.