Skip to content

Other engines

AI Summary

A short gist of this page, generated for you.

Powered by AI. Summaries can miss nuance — when in doubt, read the page.

The SDK is plain JavaScript, so any engine that exports to HTML5 or WebGL can use it. The recipe is always the same two steps.

#The recipe

1. Load the SDK on the exported page. Add this to the exported index.html, before the engine's own scripts:

html
<script src="https://funox.com/sdk/v1/funox-sdk.js"></script>

Most engines let you do this once, in an HTML template or a "head include" setting, so you do not have to edit the file after every export.

2. Call the global FunOxSDK through your engine's JavaScript bridge. Every engine that targets the web has one. You need at least the four required calls:

javascript
FunOxSDK.init();
FunOxSDK.gameplayStart();
FunOxSDK.gameplayStop();
FunOxSDK.commercialBreak().then(function () { /* resume the game */ });

When you upload, pick your engine in the form, or Custom / Other if it is not listed.

#GDevelop

Use a JavaScript code event.

At the beginning of the scene:

javascript
FunOxSDK.init().then(function () {
  runtimeScene.getVariables().get("sdkReady").setBoolean(true);
  return FunOxSDK.getUser();
}).then(function (user) {
  if (user) {
    runtimeScene.getVariables().get("playerName").setString(user.name);
  }
});

When the player starts playing, and when the game is over:

javascript
FunOxSDK.gameplayStart();
javascript
FunOxSDK.gameplayStop();

For an ad break, set a scene variable when the ad has finished and resume from a normal event that checks it:

javascript
runtimeScene.getVariables().get("adDone").setBoolean(false);

FunOxSDK.commercialBreak()
  .catch(function () {})
  .then(function () {
    runtimeScene.getVariables().get("adDone").setBoolean(true);
  });

#PlayCanvas, Three.js, Babylon.js

These are JavaScript engines, so follow the HTML5 / JavaScript guide as written. In a PlayCanvas project, add the SDK script tag to the exported index.html and call FunOxSDK from your scripts.

#Defold

Defold's HTML5 build can run JavaScript with html5.run(). Add the SDK script tag to your custom HTML template, then:

lua
if html5 then
  html5.run("FunOxSDK.init()")
  html5.run("FunOxSDK.gameplayStart()")
end

For calls that finish later, such as an ad break, have the JavaScript set a flag on window and read it back with html5.run() from your update loop.

#When a call finishes later

Ad breaks, saves and loads are asynchronous. If your engine cannot receive a JavaScript callback directly, use a flag:

javascript
window.funoxAdDone = false;
FunOxSDK.commercialBreak()
  .catch(function () {})
  .then(function () { window.funoxAdDone = true; });

Then check window.funoxAdDone from your game loop and resume when it is true.

#Check your work

Whatever the engine, upload the build and watch the portal preview. Its live feed shows each SDK call as your game makes it, and the checklist turns green when the four required calls have fired.