Home

Game Distribution edited this page Mar 14, 2016 · 15 revisions
Clone this wiki locally

Welcome to the GD-HTML5 wiki!

Methods

/**
 * Shows banner, you can use it between levels
 */     
gdApi.showBanner();         

/**
 * GD Logger sends how many times 'PlayGame' is called. If you invoke 'PlayGame' many times, it increases 
 * 'PlayGame' counter and sends this counter value. 
 */     
gdApi.play();

/**
 * GD Logger sends how many times 'CustomLog' that is called related to given by _key name. If you invoke 
 * 'CustomLog' many times, it increases 'CustomLog' counter and sends this counter value. 
 * @param   key     Your custom key it should be maximum 10 chars
 */     
gdApi.customLog(Key:String);

Settings

var settings = {
    gameId: "<Your Game Id, you can find it after upload a game to GameDistribution>",
    userId: "<Your UserId>",
    resumeGame: <Callback function for resuming your game after banner closed>,
    pauseGame: <Callback function for pausing your game when Ads will be shown>,
    onInit: function (data) {
        console.log("Init:"+data);
    },
    onError: function (data) {
        console.log("Error:"+data);
    }
};

Example

/**
 * Example
     * Working example: http://www.gamedistribution.com/Games/Basketball/Basket-and-Ball.html
 */
<script>
    var settings = {
        gameId: "4f3d7d38d24b740c95da2b03dc3a2333",
        userId: "31D29405-8D37-4270-BF7C-8D99CCF0177F-s1",
        resumeGame: resumeGame,
        pauseGame: pauseGame,
        onInit: function (data) {
            console.log("Init:"+data);
            //gdApi.customLog("Level 1");

            setTimeout(function(){
                //gdApi.customLog("Level 1");
                //gdApi.play();
                //gdApi.showBanner();
            },10000);
            //gdApi.showBanner("{_key:"level"+level}");
        },
        onError: function (data) {
            console.log("Error:"+data);
        }
    };
    (function(i,s,o,g,r,a,m){
        i['GameDistribution']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)};i[r].l=1*new Date();a=s.createElement(o);m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a, m);
    })(window, document, 'script', '//html5.api.gamedistribution.com/libs/gd/api.js', 'gdApi');
    gdApi(settings);


    function resumeGame() {
        console.log("Resume game");
    }

    function pauseGame() {
        console.log("Pause game");
    }
</script>