Construct
AI Summary
A short gist of this page, generated for you.
Powered by AI. Summaries can miss nuance — when in doubt, read the page.
Construct 3 projects call the SDK through the Browser object, which runs JavaScript on the page where the SDK lives.
#Install
- Add the Browser object to your project.
- Export your project as HTML5.
- Open the exported
index.htmland add the SDK inside<head>, before the other scripts:
<script src="https://funox.com/sdk/v1/funox-sdk.js"></script>You need to add this line again each time you export.
#Initialize
On Start of layout of your first layout, add the action Browser → Execute JavaScript:
FunOxSDK.init();#Gameplay signals
On Start of layout of your game layout (not the menu):
FunOxSDK.gameplayStart();On End of layout, or when the game is over:
FunOxSDK.gameplayStop();#Ad break
An ad takes time, so the event sheet needs to know when it has finished. Set a flag from JavaScript and check it from an event.
- At a natural break, pause your game (set the time scale to 0 and silence audio), then run Browser → Execute JavaScript:
window.funoxAdDone = false;
FunOxSDK.commercialBreak()
.catch(function () {})
.then(function () { window.funoxAdDone = true; });- Add an event with the condition System → Compare two values:
Browser.ExecJS("window.funoxAdDone ? 1 : 0") = 1- In that event, run Execute JavaScript with
window.funoxAdDone = false;, then resume the game.
A rewarded ad works the same way — store the result so the event sheet can read it:
window.funoxRewardEarned = -1; // -1 waiting, 0 no reward, 1 reward earned
FunOxSDK.rewardedBreak('extra_life')
.then(function (result) { window.funoxRewardEarned = result.completed ? 1 : 0; })
.catch(function () { window.funoxRewardEarned = 0; });Grant the reward only when Browser.ExecJS("window.funoxRewardEarned") equals 1.
#Save data
FunOxSDK.saveProgress({ level: 5, score: 12400 }).catch(function () {});To load, store the result where the event sheet can read it:
window.funoxSave = '';
FunOxSDK.loadProgress().then(function (data) {
window.funoxSave = data ? JSON.stringify(data) : '{}';
});Read it with Browser.ExecJS("window.funoxSave") once it is no longer empty, and parse it with the JSON object.
#Tips
- Call
gameplayStart()on the game layout, not on the loading or menu layout. - Run every SDK call through the Browser object. Script files that run in a worker cannot see
FunOxSDK. - Check the result in the portal preview — the live feed shows each call as it happens.