/phaser-core
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,
$ npx -y skills add gamedev-skills/awesome-gamedev-agent-skills --skill phaser-core --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
- You can call itInvoke it directly when you want it.
- Slash command
/phaser-core
Context preview
The summary Claude sees to decide when to auto-load this skill.
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,
SKILL.md
phaser-core.SKILL.mdname: phaser-core
description: >
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.
Phaser 4 Core
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.
When to use
- Use when starting a Phaser game, wiring the `Phaser.Game` config, structuring
`Scene`s, loading assets in `preload`, or fixing scene transitions and shared state.
- Use when the project has `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`.
Core workflow
1. **Detect the installed major first.** Read `package.json` and the lockfile. Use Phaser 4.2 for new work; do not silently rewrite a Phaser 3 project as Phaser 4. 2. **Create the game from a config.** `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. 3. **Model each screen as a `Scene`.** Subclass `Phaser.Scene`, pass a unique `key` to `super`, and implement the lifecycle: `init(data)` → `preload()` → `create(data)` → `update(time, delta)`. 4. **Load assets in `preload`, use them in `create`.** Queued assets are not available until `create`. The loader is per-scene; the cache it fills is global. 5. **Reset per-run state in `init()`, not the constructor.** A scene instance is reused across restarts, so constructor-set fields keep stale values. 6. **Move between screens** with `this.scene.start/launch/switch/sleep/wake`. Share data through `this.registry` (global) or a sibling scene's event emitter. 7. **Run and observe.** Serve the page, open it, and confirm assets load (watch the Network tab and console) and scenes switch as expected before assuming success.
Patterns
1. Game config + boot (ES module)
// 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);2. A Scene with the full lifecycle
// 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;
}
}3. Cross-scene data + events
// 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!');4. Scene transitions (pick the right verb)
this.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 wake5. A camera that follows the player
this.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);
Pitfalls
- **Assets are `undefined` in `create`/`update`** → you forgot to queue them in
`preload`, or used the wrong key. The loader runs between `preload` and `create`.
- **State leaks across a restart** → you set fields in the constructor. The Scene
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
Read more
name: phaser-core description: > 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.
Phaser 4 Core
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.
When to use
- Use when starting a Phaser game, wiring the `Phaser.Game` config, structuring
`Scene`s, loading assets in `preload`, or fixing scene transitions and shared state.
- Use when the project has `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`.
Core workflow
1. **Detect the installed major first.** Read `package.json` and the lockfile. Use Phaser 4.2 for new work; do not silently rewrite a Phaser 3 project as Phaser 4. 2. **Create the game from a config.** `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. 3. **Model each screen as a `Scene`.** Subclass `Phaser.Scene`, pass a unique `key` to `super`, and implement the lifecycle: `init(data)` → `preload()` → `create(data)` → `update(time, delta)`. 4. **Load assets in `preload`, use them in `create`.** Queued assets are not available until `create`. The loader is per-scene; the cache it fills is global. 5. **Reset per-run state in `init()`, not the constructor.** A scene instance is reused across restarts, so constructor-set fields keep stale values. 6. **Move between screens** with `this.scene.start/launch/switch/sleep/wake`. Share data through `this.registry` (global) or a sibling scene's event emitter. 7. **Run and observe.** Serve the page, open it, and confirm assets load (watch the Network tab and console) and scenes switch as expected before assuming success.
Patterns
1. Game config + boot (ES module)
// 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);2. A Scene with the full lifecycle
// 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;
}
}3. Cross-scene data + events
// 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!');4. Scene transitions (pick the right verb)
this.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 wake5. A camera that follows the player
this.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);
Pitfalls
- **Assets are `undefined` in `create`/`update`** → you forgot to queue them in
`preload`, or used the wrong key. The loader runs between `preload` and `create`.
- **State leaks across a restart** → you set fields in the constructor. The Scene
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
<img src="docs/assets/banner.png" width="820" alt="awesome-gamedev-agent-skills — game-dev skills for AI coding agents.
Repo: gamedev-skills/awesome-gamedev-agent-skills
Other skills on awesome-gamedev-agent-skills.
- /audio-design
Implement game audio practice — bus/mixer architecture and gain in decibels, ducking (sidechain), adaptive/dynamic music via layering and re-sequencing, SFX variation, and beat synchronization. Engine-neutral. Use when the user mentions audio mixing, audio buses,
Open skill - /camera-systems
Build game cameras that feel good — 2D follow with a deadzone, look-ahead, smoothing, and level-bounds clamping; 3D third-person orbit with collision and first-person look; plus multi-target framing and a shake hook. Engine-neutral techniques that pair with the engine's camera
Open skill - /create-game-assets
Plan, generate, source, normalize, and validate cohesive visual game assets. Use for art direction, style bibles, sprites, tilesets, backgrounds, UI art, icons, textures, concept art, or 3D asset briefs.
Open skill - /dialogue-systems
Build branching dialogue and narrative — a node/choice graph with conditions, variables, and localization hooks — and choose between authoring tools Ink and Yarn Spinner or a custom data-driven runner. Engine-neutral. Use when the user mentions dialogue system, branching
Open skill - /game-ai
Design NPC and enemy decision-making with finite state machines, behavior trees, steering behaviors, and A* pathfinding — engine-neutral algorithms that pair with the detected engine's navigation API. Use when building enemy AI, an FSM or behavior tree, steering/flocking, or
Open skill - /game-feel
Add "juice" and game feel that makes actions satisfying — screen shake, hit-stop/freeze frames, tweened/eased motion, squash & stretch, knockback, and layered audio-visual feedback — as engine-neutral techniques that pair with the detected engine's tween, particle, and camera
Open skill

