Skip to content
martinzakovec edited this page Mar 18, 2020 · 3 revisions

In this section you'll find the API Reference for the gamee-js framework. If you're starting a new game, we recommend always using our latest version of the gamee-js.


gamee.gameInit

Initial handshake method, game notifies Gamee platform about its existence. After calling this command (before the callback is being called), the game is supposed to listen to mute and unmute events.
In this phase, the game is covered with semi-transparent layer.

Simplest example

// signature: gameCapabilities, callback
gamee.gameInit([], function(error, data) {
    if(error !== null)
        throw error;

    var sound = data.sound;
... // your code that should make game ready
});

gamee.gameReady

Being called when the game is ready to start. It signals that the game is able to receive start event.

Simplest example

gamee.gameReady();

Complete usage

gamee.gameReady(function(error) {
    if(error !== null)
        throw error;
});

gamee.updateScore

Updates the score making it visible for the player. Also, the score is being saved. Should be called with every score change.

Simplest example

gamee.updateScore(10); // set score to 10

Another usage

gamee.updateScore(10, function(error) {
    if(error !== null)
        throw error;
});

gamee.gameOver

Notifies the platform that the player ended the game. The game will be covered with the results layer after this function is called.

Simplest example

gamee.gameOver();

Another usage

gamee.gameOver(function(error) {
    if(error !== null)
        throw error;
});

gamee.emitter

Emitting these major events: "start", "pause", "resume", "mute" and "unmute".

Simplest usage

// Will be emitted when user will start game or restart it. 
gamee.emitter.addEventListener("start", function(event) {
   ... // your code to start

   event.detail.callback();
}); 

// Will be emitted when user paused the game. 
gamee.emitter.addEventListener("pause", function(event) {
   ... // your code to pause the game

   event.detail.callback();
}); 

// Will be emitted after user resumes the game after 
// pause or GameeApp suspension. 
gamee.emitter.addEventListener("resume", function(event) {
   ... // your code to unpause the game

   event.detail.callback();
});

// Will be emitted when user clicks the mute button 
// and the game must mute all game sounds.
gamee.emitter.addEventListener("mute", function(event) {
   ... // your code to make game silent

   event.detail.callback();
});

// Will be emitted when user clicks the unmute button
// and the game should unmute all game sounds.
gamee.emitter.addEventListener("unmute", function(event) {
   ... // your code to make game produce sound again

   event.detail.callback();
});