Cocos
Funox supports Cocos Creator HTML5 builds via the standard HTML5 SDK plus a small Cocos wrapper.
Install
-
In your
build-templates/web-mobile/index.html(orweb-desktop/index.html), add the Funox SDK before the Cocos bootstrap:1<script src="https://sdk.funox.com/funox-sdk-v1.js"></script> -
Download the optional
funox-cocos.jshelper from the Developer Portal and place it inassets/scripts/.
Initialize
In your bootstrap scene's main script:
1import { _decorator, Component } from 'cc';2const { ccclass } = _decorator;3 4declare const Funox: any;5 6@ccclass('Boot')7export class Boot extends Component {8 async start() {9 await Funox.SDK.init();10 console.log('Funox SDK ready');11 }12}Lifecycle
1Funox.SDK.game.gameplayStart();2Funox.SDK.game.gameplayStop();3Funox.SDK.game.loadingStart();4Funox.SDK.game.loadingStop();5Funox.SDK.game.happytime();Video ads
1Funox.SDK.ad.requestAd('midgame', {2 adStarted: () => cc.audioEngine.pauseAll(),3 adFinished: () => cc.audioEngine.resumeAll(),4 adError: () => cc.audioEngine.resumeAll(),5});Save data
1Funox.SDK.data.setItem('highScore', '12450');2const score = Funox.SDK.data.getItem('highScore');Build settings
- Template: web-mobile for best mobile compatibility
- Compression: gzip or brotli at your CDN
- Auto-merge JSON: on
- Subpackages: keep the initial subpackage ≤ 20 MB for mobile featuring