Skip to main content

Game module

The game module is how your game tells Funox what is happening: when the player is actively playing, when they're in a menu, when a level loads, and when something exciting happens. These signals power our analytics, ad pacing, and quality reviews.

Required for Basic Launch

At minimum, you must call gameplayStart() when active play begins.

gameplayStart()

Call when the player begins or resumes active gameplay: a level starts, the player un-pauses, or a new run begins.

JavaScript1 line
1window.Funox.SDK.game.gameplayStart();

gameplayStop()

Call when active gameplay is interrupted: pause menu opened, level finished, game over, or the player navigates to a non-gameplay screen.

JavaScript1 line
1window.Funox.SDK.game.gameplayStop();

loadingStart() / loadingStop()

Track loading screens explicitly. Call loadingStart() when a loading screen appears, and loadingStop() when the loading completes and the player can interact.

JavaScript3 lines
1window.Funox.SDK.game.loadingStart();2// ... load assets, build scene3window.Funox.SDK.game.loadingStop();

These are optional but help us measure load performance.

happytime()

Call when the player accomplishes something significant — a personal best, finishing a hard level, unlocking a rare item. Funox uses this to trigger celebratory UI on the page hosting your game (confetti, highlighted state, etc.).

JavaScript1 line
1window.Funox.SDK.game.happytime();

Use sparingly. Once every few minutes at most.

setGameContext()

Attach contextual metadata to subsequent events. Useful for level-aware analytics.

JavaScript1 line
1window.Funox.SDK.game.setGameContext({ level: 12, mode: "hard" });

clearGameContext()

Remove the attached context.

JavaScript1 line
1window.Funox.SDK.game.clearGameContext();

settings

Read the current player-selected settings on the Funox page (e.g., preferred language, parental controls).

JavaScript2 lines
1const settings = window.Funox.SDK.game.settings;2// { locale: "en", muteByDefault: false, ... }

addSettingsChangeListener(listener)

Register a callback that fires whenever Funox-level settings change.

JavaScript4 lines
1const handler = (settings) => {2  console.log("Settings changed:", settings);3};4window.Funox.SDK.game.addSettingsChangeListener(handler);

To remove:

JavaScript1 line
1window.Funox.SDK.game.removeSettingsChangeListener(handler);

Putting it together

JavaScript14 lines
1await window.Funox.SDK.init();2 3window.Funox.SDK.game.loadingStart();4await loadAssets();5window.Funox.SDK.game.loadingStop();6 7// Player taps Play8window.Funox.SDK.game.gameplayStart();9 10// Player dies11window.Funox.SDK.game.gameplayStop();12 13// Player gets a new high score14window.Funox.SDK.game.happytime();