Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Set up and debug a Phaser 4 game: the Game config, the Scene lifecycle (init/preload/create/update), the asset loader, cameras, and cross-scene communication. Use when building or debugging a Phaser game — when the user mentions Phaser, Phaser.Game, Phaser.Scene, preload/create/update, this.load, this.add, or scene transitions. For Arcade Physics movement/collisions use phaser-arcade-physics.
.claude/skills/gamedev-skills-phaser-core/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-02 | ✗→✓ | ▲ Improved | 70% | 0% |
| case-06 | ✗→✓ | ▲ Improved | 242% | 0% |
| case-22 | ✓→✓ | = Same ✓ | 255% | 0% |
| case-03 | ✓→✓ | = Same ✓ | 46% | 0% |
| case-05 | ✓→✓ | = Same ✓ | 1% | 0% |
Set up the foundation of a Phaser game: the Game config, the Scene lifecycle, asset loading, cameras, and passing data between scenes. Targets Phaser 4.2 for new projects; keep an existing Phaser 3.90 project on its pinned major unless the user explicitly asks for a migration.
Phaser.Game config, structuringScenes, loading assets in preload, or fixing scene transitions and shared state.
phaser in package.json or import Phaser from 'phaser',and code uses preload()/create()/update().
When not to use: movement, velocity, colliders, gravity, or overlap → use phaser-arcade-physics. Complex rigid-body simulation uses Matter physics (a separate concern). For cross-engine save/load patterns use save-systems.
package.json and the lockfile. UsePhaser 4.2 for new work; do not silently rewrite a Phaser 3 project as Phaser 4.
new Phaser.Game(config) with type:Phaser.AUTO (WebGL with Canvas fallback), a width/height, and a scene array. The first scene (and any with active: true) starts automatically.
Scene. Subclass Phaser.Scene, pass a uniquekey to super, and implement the lifecycle: init(data) → preload() → create(data) → update(time, delta).
preload, use them in create. Queued assets are notavailable until create. The loader is per-scene; the cache it fills is global.
init(), not the constructor. A scene instance isreused across restarts, so constructor-set fields keep stale values.
this.scene.start/launch/switch/sleep/wake.Share data through this.registry (global) or a sibling scene's event emitter.
Network tab and console) and scenes switch as expected before assuming success.
js// main.js — one Game owns the renderer, loop, cache, and Scene Manager. import Phaser from 'phaser'; import BootScene from './scenes/BootScene.js'; import PlayScene from './scenes/PlayScene.js'; const config = { type: Phaser.AUTO, // WebGL if available, else Canvas width: 800, height: 600, backgroundColor: '#1d1d28', scale: { mode: Phaser.Scale.FIT, autoCenter: Phaser.Scale.CENTER_BOTH }, scene: [BootScene, PlayScene] // BootScene starts first }; new Phaser.Game(config);
js// scenes/PlayScene.js import Phaser from 'phaser'; export default class PlayScene extends Phaser.Scene { constructor() { super('play'); // unique scene key } init(data) { // Reset run-specific state HERE so restarts start clean. this.score = 0; this.level = data.level ?? 1; } preload() { // Queue downloads. Not usable until create(). this.load.image('player', 'assets/player.png'); this.load.spritesheet('coin', 'assets/coin.png', { frameWidth: 16, frameHeight: 16 }); } create() { this.player = this.add.sprite(400, 300, 'player'); this.scoreText = this.add.text(10, 10, 'Score: 0', { fontSize: '20px', color: '#fff' }); this.cursors = this.input.keyboard.createCursorKeys(); } update(time, delta) { // delta is milliseconds since last frame; divide by 1000 for seconds. const speed = 200 * (delta / 1000); if (this.cursors.left.isDown) this.player.x -= speed; if (this.cursors.right.isDown) this.player.x += speed; } }
js// The registry is a global DataManager shared by every scene. this.registry.set('coins', 0); // in any scene const coins = this.registry.get('coins'); // read anywhere // React to registry changes (e.g. a HUD scene listening to gameplay): this.registry.events.on('changedata-coins', (parent, value) => { this.coinText.setText(`Coins: ${value}`); }); // Talk directly to another running scene via its event emitter: const ui = this.scene.get('hud'); ui.events.emit('show-message', 'Level cleared!');
jsthis.scene.start('gameover', { score: this.score }); // stop this scene, start target this.scene.launch('hud'); // run a second scene in parallel (overlay HUD) this.scene.switch('menu'); // sleep this scene, start/wake target this.scene.pause(); // freeze updates but keep rendering (modal) this.scene.sleep(); // stop updating AND rendering, keep state for wake
jsthis.cameras.main.setBounds(0, 0, 1600, 1200); // world size this.cameras.main.startFollow(this.player, true, 0.1, 0.1); // smooth lerp follow this.cameras.main.setZoom(1.5);
undefined in create/update → you forgot to queue them inpreload, or used the wrong key. The loader runs between preload and create.
instance is reused; reset run state in init() and clear arrays on shutdown.
this.scene.start vs this.scene.launch → start stops the calling scene;launch runs the target alongside it. Using start for a HUD hides the game.
this is wrong in a callback → arrow functions keep the Scene's this; plainfunction callbacks need a context argument or .bind(this).
and each Scene owns its own systems (input, cameras, tweens) rather than a global Game World.
replaced the old FX/pipeline extension points. Migrate custom shaders and renderer plugins against the Phaser 4 guide; do not mechanically copy internal renderer code.
width/heightare set, and a scene actually started (check game.scene.dump() output).
restart-state bug, and removing/replacing scenes), read references/scene-flow.md.
phaser-arcade-physics — velocity, gravity, colliders, overlap, and groups.input-systems — rebindable, multi-device input architecture (engine-agnostic).pixijs-rendering / threejs-scene-setup — other browser rendering stacks.platformer / puzzle — genre templates that compose Phaser skills.| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→fail | 22,265 | 17,339 | -22% | 1 | 1 | 0% | 3,488 | 4,508 | +29% | 0 | 0 | — |
case-22 | pass→pass | 4,374 | 3,713 | -15% | 1 | 1 | 0% | 727 | 2,583 | +255% | 0 | 0 | — |
case-02 | fail→pass | 14,923 | 12,851 | -14% | 1 | 1 | 0% | 2,040 | 3,478 | +70% | 0 | 0 | — |
case-03 | pass→pass | 17,729 | 15,262 | -14% | 1 | 1 | 0% | 2,796 | 4,088 | +46% | 0 | 0 | — |
case-04 | fail→fail | 25,073 | 19,084 | -24% | 1 | 1 | 0% | 5,230 | 5,863 | +12% | 0 | 0 | — |
case-05 | pass→pass | 29,448 | 19,279 | -35% | 1 | 1 | 0% | 4,865 | 4,923 | +1% | 0 | 0 | — |
case-06 | fail→pass | 4,375 | 5,064 | +16% | 1 | 1 | 0% | 827 | 2,831 | +242% | 0 | 0 | — |
case-07 | pass→pass | 15,689 | 6,537 | -58% | 1 | 1 | 0% | 2,055 | 3,139 | +53% | 0 | 0 | — |
case-08 | pass→pass | 12,697 | 11,469 | -10% | 1 | 1 | 0% | 1,441 | 3,141 | +118% | 0 | 0 | — |
case-09 | pass→pass | 12,033 | 8,714 | -28% | 1 | 1 | 0% | 1,760 | 3,436 | +95% | 0 | 0 | — |
case-10 | pass→pass | 9,348 | 13,592 | +45% | 1 | 1 | 0% | 1,799 | 3,462 | +92% | 0 | 0 | — |
case-11 | pass→pass | 7,825 | 6,390 | -18% | 1 | 1 | 0% | 1,451 | 3,183 | +119% | 0 | 0 | — |
case-12 | pass→pass | 10,109 | 5,228 | -48% | 1 | 1 | 0% | 1,070 | 2,981 | +179% | 0 | 0 | — |
case-13 | pass→pass | 7,728 | 6,018 | -22% | 1 | 1 | 0% | 1,529 | 3,123 | +104% | 0 | 0 | — |
case-14 | pass→pass | 6,648 | 5,894 | -11% | 1 | 1 | 0% | 1,349 | 3,063 | +127% | 0 | 0 | — |
case-15 | pass→pass | 19,208 | 11,848 | -38% | 1 | 1 | 0% | 2,928 | 3,820 | +30% | 0 | 0 | — |
case-16 | pass→pass | 12,328 | 9,905 | -20% | 1 | 1 | 0% | 2,498 | 3,964 | +59% | 0 | 0 | — |
case-17 | pass→pass | 15,345 | 11,269 | -27% | 1 | 1 | 0% | 2,560 | 3,928 | +53% | 0 | 0 | — |
case-18 | pass→pass | 12,147 | 11,517 | -5% | 1 | 1 | 0% | 2,061 | 4,035 | +96% | 0 | 0 | — |
case-19 | pass→pass | 11,746 | 6,225 | -47% | 1 | 1 | 0% | 2,108 | 3,173 | +51% | 0 | 0 | — |
case-20 | pass→pass | 5,603 | 4,689 | -16% | 1 | 1 | 0% | 1,044 | 2,663 | +155% | 0 | 0 | — |
case-21 | pass→pass | 2,641 | 2,452 | -7% | 1 | 1 | 0% | 401 | 2,317 | +478% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of +9 percentage points is the difference between those two pass rates over the 22 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.