-
Notifications
You must be signed in to change notification settings - Fork 17
Home
Game Distribution edited this page Jul 13, 2017
·
31 revisions
Welcome to the GD-HTML5 wiki!
/**
* It is used to initialize api.
*/
initGDApi();
/**
* Shows ad, you can use it to show midroll
*/
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);
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
* Working example: http://www.gamedistribution.com/Games/Basketball/Basket-and-Ball.html
*/
<script>
var initialized = false;
function initGDApi(){ // invoke this function to initialize api
if(!initialized){ // Api will be initialized once, so preroll is shown once either
var settings = {
gameId: "4f3d7d38d24b740c95da2b03dc3a2333",
userId: "31D29405-8D37-4270-BF7C-8D99CCF0177F-s1",
resumeGame: resumeGame,
pauseGame: pauseGame,
onInit: function (data) {
initialized = true;
},
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");
}
}
}
initGDApi(); // in order to initialize api
</script>
Gamedistribution.com offers a free service for developers and publishers. We help game developers monetize and distribute their games. We offer publishers a wide range of high quality cross platform games.