Skip to contentGo to cookie choices
Skip to docs navigation

Bring a Godot game

https://docs.zokogames.com/porting/godot

For a Godot game that already ships as a Web export on other web game portals. You keep the project; you enable the zokogames addon, switch the export's HTML shell and replace the portal calls. The full reference is the Godot engine page, which also covers Godot 3. The overall route is in bring your game.

1. Export settings#

Copy addons/zokogames into res://addons/ and enable ZokoGames under Project > Project Settings > Plugins, as in Godot: install. Then check the Web export preset:

Setting On ZokoGames
Custom HTML Shell res://addons/zokogames/export/zokogames_shell.html. It loads the SDK before the engine and defines the bridge the autoload talks to. If your old shell held another portal's script, replace it; with a shell of your own, copy the bridge block across.
Thread Support Off. The portal frame is not cross-origin isolated, so a threaded export does not start. Godot 4.3 and later export single-threaded by default.
File names Keep index.html, index.js, index.wasm, index.pck as exported. Do not rename them to .br or .gz: Godot requests the plain names.
Texture compression VRAM compression for desktop and mobile, so every browser has a format.
Stretch Stretch Mode canvas_items with aspect expand or keep: the frame changes size with fullscreen and rotation.
Export With Debug Off.

Details: web export settings that matter.

2. Replace the platform calls#

Remove the other portal's shell code, scripts and autoloads first. Then await ZokoGames.init_async() once at startup and map each call:

Your game does With the ZokoGames autoload
Start the SDK await ZokoGames.init_async(); ZokoGames.is_available() is false when the SDK is disabled, and the game must still run.
Loading finished Nothing to write for the engine download: the shell sends loadingStart and loadingStop once the engine has started. For a longer loading screen of your own call ZokoGames.loading_start(), loading_progress(percent) and loading_stop().
Gameplay start and stop ZokoGames.gameplay_start() and gameplay_stop().
Midgame ad (an interstitial or commercial break) await ZokoGames.request_ad_async("midgame"). It completes after the ad is over, whatever the outcome.
Rewarded ad await ZokoGames.request_ad_async("rewarded"); grant the reward only when the result's ok is true.
Pause and mute during ads Nothing to write: the addon pauses the tree and mutes Master from ad_started until ad_finished or ad_error, and follows the portal's mute setting. Nodes that must keep running need the Always process mode.
Cloud save ZokoGames.data_set_item(key, value) and data_get_item(key, default), synchronous Strings.
Leaderboard score await ZokoGames.submit_score_async(encrypted_score, score) for a signed-in player, on a board created in the console. No wrapper builds the encrypted payload; see leaderboards.
Purchases store_get_catalog_items_async, store_buy_item_async(item_id), store_consume_item_async(sku, qty). Purchases are test purchases for now (purchases).
Sign-in prompt, player await ZokoGames.show_auth_prompt_async(), await ZokoGames.get_user_async().

A complete script with init, both ads, save and score is in a working script; every call is in how calls work. Godot's own user:// files live in the browser's IndexedDB and stay on one device; move progress you want kept into data_set_item.

The compatibility shim is for JavaScript call sites only. A Godot game calls the autoload from GDScript, so it does not need the shim.

3. Build size and mobile#

  • Budget: 1,500 files, 250 MB unpacked, about 50 MB initial download (20 MB for mobile), estimated from uncompressed sizes. Keep the .wasm and .pck small.
  • A custom export template with unused modules disabled cuts the engine itself.
  • Load later levels after the first scene with ResourceLoader.load_threaded_request, which still works in a non-threaded export.
  • Cap the resolution on phones and start audio from a "click to play" screen; see mobile.

4. Test before you submit#

  1. In the editor the simulator answers (ZokoGames.is_simulated). Its settings are under Project Settings > zokogames/simulator: ad fill, no fill and error, an ad blocker, a logged-out player, a disabled SDK.
  2. The Web export on localhost (a local web server, not a file opened from disk) runs the SDK's local mode, which also enforces the three-minute midgame cooldown the simulator skips. See Godot: test locally.
  3. Upload the zip (export folder contents, index.html at the archive root) and open the game's Preview and QA tab in the developer console to run the build in the portal frame with ads on (build preview).

Checklist#

  • Addon enabled; custom HTML shell set; the other portal's shell code and scripts removed.
  • Thread Support off; file names as exported.
  • init_async first; the game plays when is_available() is false.
  • Gameplay start and stop at the right moments.
  • Rewards only when the rewarded ad finished; your own nodes behave while the tree is paused.
  • Saves through data_set_item; scores on a board created in the console.
  • Other portal's logos, links and sitelock removed.
  • Tested on localhost and in Preview and QA.

Next#

Something unclear, wrong or missing on this page? Tell us through support · Test your game in the preview tool