Phaser integration
Native Phaser setup, integration source and export guidance.
Downloads for this guide
Phaser source packageSource + configuration/adapter + README; engine verification notes included.Download game.jsIndividual native integration source.Support and prerequisites
Verified in local desktop and mobile-viewport Chromium: this bundled starter rendered inside Play Island's real sandbox and sent an accepted start event. Complete gameplay, other renderers and physical devices still require release-specific testing. 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
Use Node 22+, run npm install, then npm run build in the extracted project. The package targets Phaser 3.90.0 and bundles the engine locally with esbuild into build/game.js. CollectScene.create registers an interactive circle and removes its pointer listener on scene shutdown. Never emit reports from update(). ZIP the contents of build/ with index.html at root. The engine runtime and this scene require browser verification for your release.
Native integration example
import Phaser from 'phaser';
// Phaser 3: reports follow actual pointer input, never the per-frame update loop.
class CollectScene extends Phaser.Scene {
create() {
const status = this.add.text(24,24,'Connecting…',{fontSize:'20px',wordWrap:{width:660}});
const star = this.add.circle(360,270,45,0xc4f66b).setInteractive();
let count = 0, busy = true, startedAt = 0, ended = false;
const collect = async () => {
if (busy || ended) return; busy = true;
try {
if (count < 5) {
count++; await PIExample.report('progress',{progress:count*20});
star.setPosition(80+Math.random()*560,150+Math.random()*260);
status.setText(`${count}/5 stars. Tap again after 4 seconds to finish.`);
} else if (performance.now()-startedAt >= 4000) {
await PIExample.report('completed',{score:50,progress:100});
ended = true; star.disableInteractive(); status.setText('Run accepted. Reload to play again.');
}
busy = false;
} catch (error) { status.setText(error.message+' Reload after fixing the integration.'); }
};
star.on('pointerdown',collect);
this.events.once(Phaser.Scenes.Events.SHUTDOWN,() => star.off('pointerdown',collect));
PIExample.connect().then(() => PIExample.report('started',{})).then(() => {
startedAt = performance.now(); busy = false; status.setText('Collect five stars.');
}).catch(error => status.setText(error.message));
}
}
new Phaser.Game({type:Phaser.AUTO,width:720,height:540,backgroundColor:'#10251d',scene:CollectScene,scale:{mode:Phaser.Scale.FIT,autoCenter:Phaser.Scale.CENTER_BOTH}});Event 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
Phaser pointer input explains the native engine/browser mechanism. The Play Island contract is defined by the platform implementation, not by the engine documentation.