16
Ask a Question / Re: Need help integrating gamemonetize.com sdk ads in html5 stencyl game
« on: January 13, 2020, 10:38:15 pm »
nobody?
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
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();
. 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;
Here it is.Thanks a lot Liberado, this kind of variable Stencyl jump behavior Super Mario style was exactly what I was looking for.
Create also a collision event that sets to 0 the Jump attribute only when the actor is on ground.https://www.dropbox.com/s/ybcek9lq1uvl3s9/Variable%20Jump.swf?raw=1