Skip to content

Lifecycle (Cocos)

Compared with the Web SDK lifecycle, where a plain JS game must register five callbacks explicitly, Cocos needs nothing. When an interstitial or rewarded ad opens, the extension:

  • Pauses the Cocos director (your scheduler, tweens, animations stop).
  • Suspends the audio engine (music doesn’t play over the ad).
  • Resumes both when the ad closes.

You get these behaviours for free once the extension is enabled and the FRVRSDK component is attached to your first scene.

  • Loading progress. Drive the channel splash via the component’s autoTrackLoading flag, or call FRVRSDK.instance.setLoadingProgress(0..1) / completeLoading() manually. See Cocos quickstart.
  • Scene transitions. If a long‑running scene load happens after completeLoading, pause your gameplay yourself — the SDK has already handed control to your game.

If you need to react to pause/resume in game code

Section titled “If you need to react to pause/resume in game code”

Listen to Cocos’s own events — they’ll fire because the extension is driving the same pause/resume state:

import { game, Game } from 'cc';

game.on(Game.EVENT_HIDE, () => {
  // Tab backgrounded, ad opened, app minimised, …
  stopAmbientLoops();
});

game.on(Game.EVENT_SHOW, () => {
  resumeAmbientLoops();
});

Don’t try to reach into the extension’s internals — it owns the wrapper side and can change.