Hi mates, I’m trying to make an extension to integrate Game Distribution into my game but as request by Game Distribution an script must be added to the head of the index.html and a div line into body.
I managed to do it adding it after export the game but what i want to know if there is a way to add those lines from the events editor inside GDevelop 5, so I can create some sort of extension to reuse in other games.
This is how it looks like.
All previous scripts from GDevelop…
This is a script requested by Game Distribution to be added on the head
< script src=“//acdn.adnxs.com/cmp/cmp.complete.bundle.js” async>< /script>
< /head>
< body>
This is the div tag to be added in body requested by Game Distribution
< div id=“container”>
This is the script must be added requested by Game Distribution
< script>
window["GD_OPTIONS"] = {
debug: false,
gameId: "hklgjgkggggkgiylgukgykguug",
advertisementSettings: {
autoplay: true
},
onEvent: function (event) {
switch (event.name) {
case "SDK_GAME_START":
// ...
break;
case "SDK_GAME_PAUSE":
// ...
break;
case "SDK_READY":
// ...
break;
case "SDK_ERROR":
// ...
break;
case "SDK_GDPR_TRACKING":
// ..
break;
case "SDK_GDPR_TARGETING":
// ..
break;
case "SDK_GDPR_THIRD_PARTY":
// ..
break;
}
}
};
(function (d, s, id) {
var js,
fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id))
return;
js = d.createElement(s);
js.id = id;
js.src = "https://html5.api.gamedistribution.com/main.min.js";
fjs
.parentNode
.insertBefore(js, fjs);
})(document, "script", "gamedistribution-jssdk");
(function() {
//Initialization
var game = new gdjs.RuntimeGame(gdjs.projectData, {});
//Create a renderer
game.getRenderer().createStandardCanvas(document.body);
//Bind keyboards/mouse/touch events
game.getRenderer().bindStandardEvents(game.getInputManager(), window, document);
//Load all assets and start the game
game.loadAllAssets(function() {
game.startGameLoop();
});
})();
< /script >
< /body >
< /html >