Skip to main content

Video ads

The ad module shows two kinds of video ads:

  • Midgame — shown at natural breakpoints, monetizes free traffic
  • Rewarded — player-initiated, grants in-game rewards

Before shipping ads, read the advertisement requirements. Bad ad UX gets games demoted or removed.

requestAd(type, callbacks)

The core entry point. type is either "midgame" or "rewarded".

JavaScript12 lines
1window.Funox.SDK.ad.requestAd("midgame", {2  adStarted: () => {3    // Pause game, mute audio, block input4  },5  adFinished: () => {6    // Resume game, unmute audio7  },8  adError: (err) => {9    // Resume game, do NOT grant a reward10    console.log("Ad error:", err.code);11  },12});

Callbacks

CallbackWhen it firesWhat to do
adStartedThe ad video begins playingMute audio, pause game, block UI
adFinishedThe ad finishes successfullyUnmute, resume; grant reward if rewarded ad
adErrorFailure or no inventoryResume; never grant a reward

Error codes on adError

CodeMeaning
adsDisabledBasicLaunchGame is in Basic Launch — ads are off
unfilledNo ad inventory available right now
adblockAn ad blocker is active
adCooldownThe 3-minute midgame cooldown is active
otherAnything else

Your game must remain fully playable on any of these errors.

hasAdblock()

Detect whether an ad blocker is interfering. Use this to gate cosmetic perks, not core gameplay.

JavaScript4 lines
1const blocked = await window.Funox.SDK.ad.hasAdblock();2if (blocked) {3  hideRewardedButton();4}

Midgame ads

JavaScript9 lines
1function onLevelComplete() {2  window.Funox.SDK.game.gameplayStop();3 4  window.Funox.SDK.ad.requestAd("midgame", {5    adStarted: () => game.pause(true),6    adFinished: () => game.pause(false) || showNextLevel(),7    adError:    () => game.pause(false) || showNextLevel(),8  });9}
  • Max one midgame ad every 3 minutes (SDK enforced)
  • Never during active gameplay
  • Never bound to navigation/UI buttons

Rewarded ads

JavaScript13 lines
1function onWatchRewardedClick() {2  window.Funox.SDK.ad.requestAd("rewarded", {3    adStarted:  () => game.pause(true),4    adFinished: () => {5      game.pause(false);6      grantBonusLives(3);7    },8    adError: () => {9      game.pause(false);10      showFriendlyError();11    },12  });13}

Rules:

  • Always offer a non-ad alternative of equal visual weight
  • Never chain ads for one reward
  • Never grant the reward on adError

End-to-end example

JavaScript21 lines
1async function startGame() {2  await window.Funox.SDK.init();3  window.Funox.SDK.game.gameplayStart();4}5 6function onPlayerDeath() {7  window.Funox.SDK.game.gameplayStop();8 9  // Optional: offer a rewarded "extra life" first10  if (canOfferRevive()) {11    showReviveButton();12    return;13  }14 15  // Otherwise show a midgame ad before retry16  window.Funox.SDK.ad.requestAd("midgame", {17    adStarted: () => {},18    adFinished: () => showRetryScreen(),19    adError:    () => showRetryScreen(),20  });21}