Skip to content
Michal Vodicka edited this page Apr 10, 2017 · 7 revisions

Gamee framework also provides other functionalities that might be helpful. Using them is optional.


gamee.gameInit

In advance gameInit might pass gameCapabilities array which might contain "saveState", "replay", "ghostMode" and "social".

Passing capabilities example

var capabilities = ["saveState", "replay", "ghostMode", "social"];

// signature: controller, controllerOptions, gameCapabilities, callback
gamee.gameInit("OneButton", {}, capabilities, function(error, data) {
    if(error !== null)
        throw error;

    var myController = data.controller;
    var sound = data.sound;

    // based on game capabilities, you will obtain additional data
    var saveState = data.saveState;  // data is string
    var replayData = data.replayData; // data is object
    var ghostData = data.replayData;
    var socialData = data.socialData; // data is object

... // your code that should make game ready
});

gamee.updateScore

updateScore can be used to send ghost score

Passing ghost score

// signature score, ghostSign, callback
gamee.updateScore(10, true, function(error) {
    if(error !== null)
        throw error;
});

gamee.gameLoadingProgress

This currently works only with Facebook. Report the progress of initial resource loading.

Complete usage

gamee.gameLoadingProgress(50); // Assets are 50% loaded

gamee.gameSave

Simplest usage

gamee.gameSave(data, opt_share, opt_cb)

Complete usage

gamee.gameSave(data, opt_share, opt_cb)

gamee.requestSocial

Will get more social data about Gamee players.

Complete usage

gamee.requestSocial(function(error, data) {
    if (data && data.friends) {
        data.friends.forEach(function (friend) {
            console.log(friend); 
            // { name : "playerName", avatar : "url?", highScore: 1000 }
    }
});

gamee.gameOver

In addition, gameOver might send data that might be later used for replay or for ghost mode.

Complete usage

var replayData = {};

... // assign something to replay data

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

gamee.emitter

Some events like "start" comes with params. In addition this object emits also other events: "ghostHide" and "ghostShow".

Complete usage

// Will be emitted when user will start game or restart it. 
gamee.emitter.addEventListener("start", function(event) {
    ... // your code to start
    event.detail.opt_replay // if true, game must start as replay
    event.detail.opt_ghostMode // if true, game must start in ghostMode 
                               // (unless replay is true)
    event.detail.opt_resetState // if true, game should toss its current saveState

    event.detail.callback();
}); 

gamee.emitter.addEventListener("ghostHide", function(event) {
    ... // your code to hide anything related to ghost in game. 

    event.detail.callback();
});

gamee.emitter.addEventListener("ghostShow", function(event) {
    ... // your code to show anything related to ghost in game again.

    event.detail.callback();
});