
GamePix.js in extension files and you can use GamePix sdk as explained in below.
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:
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).
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:
on_gpx_lang = function(lang) {
// lang is a code of language, like en, it, ru, etc.
show_message(lang)
}
gpx_lang(on_gpx_lang)To show fullscreen interstitial AD please use following snippet:
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.
To show fullscreen rewarded AD please use following snippet:
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:
callback = function(success) {
audio_master_gain(1)
instance_activate_all()
//...
}
audio_master_gain(0)
instance_deactivate_all(false)
gpx_rewardAd(callback)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.