Godot integration
Native Godot setup, integration source and export guidance.
Downloads for this guide
Godot source packageSource + configuration/adapter + README; engine verification notes included.Download main.gdIndividual native integration source.Download Web export presetSingle-threaded Compatibility export settings.Support and prerequisites
Verified in local desktop and mobile-viewport Chromium: the exported starter loaded inside Play Island's real sandbox and completed a run with accepted start, progress and completion events. HTML5 also passed pause/resume and replay. This is not certification for every engine version or physical device. The same per-game event registration and provider approval requirements apply. Download the source package and read README.txt before building. Browser samples never need a secret key.
Set up the project
Import project.godot in Godot 4.5 with matching Web export templates. main.tscn opens the included GDScript game. Keep the Compatibility renderer, thread_support=false and PWA disabled in the Web preset. Create build/, export Web to build/index.html, then copy client.js into build/. The preset adds client.js to the HTML head. JavaScriptBridge.get_interface and retained create_callback references connect to the helper; eval is not used. Desktop editor play only previews the layout and deliberately does not simulate platform acceptance. The included project imported and exported successfully with Godot 4.5.1 and its matching single-threaded Web template. Browser/device compatibility still requires testing for your release.
Native integration example
extends Control
# Retain JavaScript callbacks for their entire lifetime. No eval() is used.
var bridge: JavaScriptObject
var ready_callback: JavaScriptObject
var ack_callback: JavaScriptObject
var error_callback: JavaScriptObject
var status_label: Label
var play_button: Button
var collect_button: Button
var finish_button: Button
var count := 0
var running := false
var busy := true
var broken := false
var started_at := 0
var action := ""
func _ready() -> void:
var box := VBoxContainer.new()
box.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
box.add_theme_constant_override("separation", 20)
add_child(box)
status_label = Label.new()
status_label.text = "Connecting to Play Island…"
status_label.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
box.add_child(status_label)
play_button = Button.new()
play_button.text = "Start run"
play_button.pressed.connect(func(): _report("started", {}))
box.add_child(play_button)
collect_button = Button.new()
collect_button.text = "Collect a star"
collect_button.pressed.connect(func(): _report("progress", {"progress": (count + 1) * 20}))
box.add_child(collect_button)
finish_button = Button.new()
finish_button.text = "Finish run"
finish_button.pressed.connect(func(): _report("completed", {"score": count * 10, "progress": 100}))
box.add_child(finish_button)
if not OS.has_feature("web"):
broken = true
status_label.text = "Editor layout preview only. Export Web and launch through Play Island for real integration."
return
bridge = JavaScriptBridge.get_interface("PIExample")
if bridge == null:
broken = true
status_label.text = "Missing client.js. Follow README.txt export instructions."
return
ready_callback = JavaScriptBridge.create_callback(_connected)
ack_callback = JavaScriptBridge.create_callback(_accepted)
error_callback = JavaScriptBridge.create_callback(_error)
bridge.connectTo(ready_callback, error_callback)
func _connected(args: Array) -> void:
var config = JSON.parse_string(str(args[0]))
status_label.text = "Connected. Locale: " + str(config.get("locale", "en"))
busy = false
func _report(name: String, payload: Dictionary) -> void:
if busy or broken:
return
busy = true
action = name
bridge.reportTo(name, JSON.stringify(payload), ack_callback, error_callback)
func _accepted(_args: Array) -> void:
if action == "started":
count = 0
running = true
started_at = Time.get_ticks_msec()
elif action == "progress":
count += 1
elif action == "completed":
running = false
status_label.text = "Accepted: %s · %d / 5 stars" % [action, count]
busy = false
func _error(args: Array) -> void:
broken = true
busy = false
status_label.text = str(args[0]) + " Reload after fixing the integration."
func _process(_delta: float) -> void:
play_button.disabled = busy or broken or running
collect_button.disabled = busy or broken or not running or count >= 5
finish_button.disabled = busy or broken or not running or count < 5 or Time.get_ticks_msec() - started_at < 4000Event lifecycle and errors
The project uses the supplied client.js helper to call the real injected PlayIsland SDK. It waits for configuration and acknowledgement callbacks. The helper serializes reports, detects rejected events and stops after a timeout or rejection. It does not manufacture accepted events offline. The example's proposed registry permits score (integer 0–1,000,000) and progress (number 0–100); both are optional in that proposal. Staff must publish the relevant definitions for your game. Other games may have different required fields. Do not copy a built-in game's specialized counters. Wait for real gameplay before reporting completion; the server rejects completed within the first three seconds of a session. Stop after terminal acceptance; use started to begin a new run or reload the launcher. On error, display the reason, correct the problem and reload to obtain a clean sequence.
Test, export and submit
- Test the engine's own rendering and controls locally. A standalone/editor launch will not connect to Play Island.
- Build using the setup instructions above and inspect the resulting runtime files.
- Follow ZIP packaging and provider submission.
- Use the visual preview for loading/layout. Use a published /play/ launch for actual accepted-event tests.
- Verify configuration, accepted start/progress/result, guest behavior, signed-in receipts if configured, replay and mobile controls.
Saves, exit, platform leaderboard navigation and general player profiles are not available automatically to your new game. See feature availability before adding those buttons.
Engine reference
Godot JavaScriptBridge explains the native engine/browser mechanism. The Play Island contract is defined by the platform implementation, not by the engine documentation.