6
« on: January 13, 2020, 01:34:03 pm »
Hello dear fellows, I need some guidance in order to integrate gamemonetize.com sdk for html5 games for one of my games.
their sdk looks like this:
STEP 1:
Add following rows into your index.html file, this will initialize GameMonetize.com SDK.
Fill gameId and and use SDK events (mute audio, pause game and after that resume game logic).
<script type = "text/javascript" >
window.SDK_OPTIONS = {
gameId: "your_game_id_here", // Fill the game_id
onEvent: function (a) {
switch (a.name) {
case "SDK_GAME_PAUSE":
// pause game logic / mute audio
break;
case "SDK_GAME_START":
// advertisement done, resume game logic and unmute audio
break;
case "SDK_READY":
// when sdk is ready
break;
case "SDK_ERROR":
// when sdk get error
break;
}
}
};
(function (a, b, c) {
var d = a.getElementsByTagName(b)[0];
a.getElementById(c) || (a = a.createElement(b), a.id = c,
a.src = "https://api.gamemonetize.com/sdk.js", d.parentNode.insertBefore(a, d))
})(document, "script", "gamemonetize-sdk");
</script>
STEP 2:
Invoke an advertisement in your game on following states: "play button", "continue game" , "new level" or when user complete every level:
sdk.showBanner();
.
Step 1 done. I have added the above code without any modification inside my index.html file.
Step 2 done. I have managed to make a call inside the behavior of my level select button so that when a user clicks on it the sdk will load and will display a test advertisement (short video of 10 seconds + audio ) that overlays the game as expected, yet the audio from the advertisement and the audio from the game will mix together.
I can't figure out how to pause the game while the test ad is playing by writing some piece of code in this section here:
case "SDK_GAME_PAUSE":
// pause game logic / mute audio
break;
For example I use the Pausing behaviour from StencylForge to pause my game and by looking at the code it's generates inside the game.js file it looks like this:
g.pause = function() {
g.engine.pause()
};
doing something like the code below on index.html doesn't work, it will break all, the sound from advertisement will play at the right moment, the game background music also plays over the sound generated by the ad, but the video for advertisement doesn't overlay, and does not take over the game graphics : case "SDK_GAME_PAUSE":
g.engine.pause(); // pause game logic / mute audio
break;
Same question for unpausing
Looking forward for some guidance.