PlayCanvas integration
Native PlayCanvas setup, integration source and export guidance.
Downloads for this guide
PlayCanvas source packageSource + configuration/adapter + README; engine verification notes included.Download play-island.jsIndividual native integration source.Support and prerequisites
Integration source adapter; the native editor/export has not been verified. Validate your actual build under Play Island's sandbox before submission. 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 the Classic scripting API. Add play-island.js to one persistent controller entity and load client.js before the application. Wait for the local app event pi:ready, then fire app.fire('pi:report','started',{}). On real completion after at least four seconds, fire app.fire('pi:report','completed',{score:50,progress:100}). Wait for pi:accepted between reports and surface pi:error. These pi:* names are local example events, not platform protocol names. The destroy handler detaches the report listener. Export a self-hosted application with local assets and index.html at root; test engine loading and CSP. This package is an adapter, not an exported Editor project.
Native integration example
// Classic PlayCanvas script. Add it once to a persistent controller entity.
// Bundle client.js and execute it before application startup.
var PlayIslandIntegration = pc.createScript('playIslandIntegration');
PlayIslandIntegration.prototype.initialize = function() {
this.ready=false; this.busy=false;
var self=this;
PIExample.connect().then(function(config) {
self.ready=true; self.app.fire('pi:ready',config);
}).catch(function(error) { self.app.fire('pi:error',error.message); });
this.handler=function(name,payload) {
if (!self.ready || self.busy) { self.app.fire('pi:error','Wait for pi:accepted before another report.'); return; }
self.busy=true;
PIExample.report(name,payload || {}).then(function(ack) {
self.busy=false; self.app.fire('pi:accepted',ack);
}).catch(function(error) { self.ready=false; self.app.fire('pi:error',error.message); });
};
this.app.on('pi:report',this.handler);
this.on('destroy',function() { self.ready=false; self.app.off('pi:report',self.handler); });
};
// pi:* are LOCAL example app events, not Play Island protocol event names.
// After pi:ready: app.fire('pi:report','started',{}).
// After actual play and at least 4 seconds: app.fire('pi:report','completed',{score:50,progress:100}).
// Gate controls until pi:accepted; display pi:error. Reload after a rejection.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
PlayCanvas script lifecycle explains the native engine/browser mechanism. The Play Island contract is defined by the platform implementation, not by the engine documentation.