Need help integrating sdk ads in html5 stencyl game


  • Posts: 38
Hello dear fellows, I need some guidance in order to integrate sdk for html5 games for one of my games.
their sdk looks like this:
Code: [Select]
Add following rows into your index.html file, this will initialize 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 ( {
            case "SDK_GAME_PAUSE":
               // pause game logic / mute audio
            case "SDK_GAME_START":
               // advertisement done, resume game logic and unmute audio
            case "SDK_READY":
               // when sdk is ready
            case "SDK_ERROR":
               // when sdk get error
(function (a, b, c) {
   var d = a.getElementsByTagName(b)[0];
   a.getElementById(c) || (a = a.createElement(b), = c,
   a.src = "", d.parentNode.insertBefore(a, d))
})(document, "script", "gamemonetize-sdk");

Invoke an advertisement in your game on following states: "play button", "continue game" , "new level" or when user complete every level:

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:
Code: [Select]
               // pause game logic / mute audio
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:
Code: [Select]
g.pause = function() {
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  :
Code: [Select]
                 g.engine.pause();  // pause game logic / mute audio

Same question for unpausing

Looking forward for some guidance.


  • *
  • Posts: 2177
Current Projects:
The Grand Grimoire Chronicles Episode 1 now on Kongregate!.
I always appreciate useful feedback. Thank you.