Phaser Gamedev Skill
Overview
This skill builds complete Phaser 3 2D games using a Phased Construction pattern: DESIGN (plan game type, physics, scenes) → BUILD (scene lifecycle, sprites, tilemaps) → ANIMATE (physics, animation state machines, input) → POLISH (camera effects, particles, tweens, sound, mobile). Targets Phaser 3.60+ throughout.
Scope: Platformers, arcade shooters, top-down RPGs, puzzle games, and side-scrollers — anything 2D in Phaser 3. Use threejs-builder for 3D games, native mobile games, and non-Phaser canvas work.
Reference Loading Table
| Signal |
Load These Files |
Why |
references/core-patterns.md |
core-patterns.md |
Always |
references/build-scaffolds.md |
build-scaffolds.md |
Phase 2 BUILD |
references/animate-scaffolds.md |
animate-scaffolds.md |
Phase 3 ANIMATE |
references/polish-scaffolds.md |
polish-scaffolds.md |
Phase 4 POLISH |
references/errors.md |
errors.md |
Error Handling |
references/arcade-physics.md |
arcade-physics.md |
Arcade physics |
references/tilemaps.md |
tilemaps.md |
Tilemap / Tiled |
references/spritesheets.md |
spritesheets.md |
Sprites / animation |
references/performance.md |
performance.md |
Performance concern |
references/game-feel-patterns.md |
game-feel-patterns.md |
Polish / juice signal |
references/tilemaps-and-physics.md |
tilemaps-and-physics.md |
Complex maps / Matter.js |
Instructions
Phase 1: DESIGN
Goal: Understand what to build, select the physics system, and plan the scene graph before writing any code.
Core constraints:
- Read repository CLAUDE.md before building — local standards override defaults here
- Select physics system before any other decision — Arcade (fast AABB), Matter.js (complex shapes), or no physics cannot be mixed per scene without deliberate design
- Plan scenes upfront — Boot → Preload → Game → UI is the standard flow; diverge only when the game requires it
Step 1: Identify the game type
From the user's request, determine: game genre (platformer, shooter, RPG, puzzle, side-scroller), primary physics need, number of scenes, tilemap or procedural world, spritesheet or texture atlas.
Step 2: Select the physics system
| Physics |
Use When |
When Not to Use |
| Arcade |
Platformers, shooters, simple AABB |
Rotating bodies, non-rectangular shapes |
| Matter.js |
Physics puzzles, destructible terrain |
Performance-critical (100+ bodies) |
| None |
Puzzles, card games, UI-only |
Any meaningful collision detection |
Step 3: Document the scene plan and load references
Write a short markdown scene plan covering: Boot, Game, UI, Physics choice, World, Sprites (measured frame dimensions).
Load these references based on the plan:
- Always:
references/core-patterns.md (scene lifecycle, transitions, input)
- If tilemap:
references/tilemaps.md
- If sprites/animation:
references/spritesheets.md
- If Arcade physics:
references/arcade-physics.md
- If performance concern or many moving objects:
references/performance.md
- If polish / game feel / juice signal ("screen shake", "particles", "game feel", "hit feedback", "satisfying"):
references/game-feel-patterns.md
- If Matter.js, slopes, object layers, complex collision, or enemy spawning from Tiled:
references/tilemaps-and-physics.md
Gate: Scene plan documented. Physics system selected. References loaded. Proceed only when gate passes.
Phase 2: BUILD
Goal: Implement the scene lifecycle skeleton, load assets, place sprites, wire up tilemaps.
Core constraints:
- MEASURE spritesheet frames before loading — wrong
frameWidth/frameHeight is the #1 Phaser bug; open the PNG, count pixels per frame before writing this.load.spritesheet()
- Preload all assets in
preload() — never load assets in create() or update()
- Use a Boot scene for asset loading — shows a progress bar, keeps Game scene clean
Full TypeScript scaffolds (entry point, BootScene with progress bar, GameScene skeleton): references/build-scaffolds.md.
Gate: Boot and Game scenes compile. Assets load without console errors. Scene transitions work. Proceed only when gate passes.
Phase 3: ANIMATE
Goal: Add physics-driven movement, animation state machines, and player input.
Core constraints:
- Never allocate objects in
update() — no new Phaser.Math.Vector2(), no this.physics.add.sprite(), no array creation per frame; allocate in create(), reuse in update()
- Use
delta for frame-rate-independent movement — velocity = speed * (delta / 1000) ensures consistent feel at any FPS
- State machine over boolean flags —
'idle' | 'walk' | 'jump' | 'attack' | 'dead' prevents impossible states like isJumping && isAttacking
Animation definitions (anims.create), the Player state machine, and input handling scaffolds: references/animate-scaffolds.md. Collision groups, overlap callbacks, and physics tuning: references/arcade-physics.md.
Gate: Player moves. Animations transition correctly. State machine has no impossible state combinations. No per-frame allocations. Proceed only when gate passes.
Phase 4: POLISH
Goal: Add camera work, particles, tweens, sound, and mobile controls. Verify performance.
Core constraints:
- Remove
debug: true from physics config before shipping
- Remove all
console.log calls unless the user explicitly requested logging
- Test on a 60 FPS budget — Arcade + 200 active bodies + 50 particles is the practical ceiling on mid-range mobile
Full scaffolds for camera effects, particles (Phaser 3.60+ API), tweens, sound, mobile virtual controls, and final verification steps: references/polish-scaffolds.md.
Gate: Polish checks pass. Performance within budget. Debug config removed. Game is shippable.
Error Handling
Common errors and fixes (spritesheet frame mismatches, undefined body access, tilemap collision no-ops, animation failures, mobile slowdowns): references/errors.md.
References
| Reference |
When to Load |
Content |
references/core-patterns.md |
Always |
Scene lifecycle, transitions, input, state machines |
references/build-scaffolds.md |
Phase 2 BUILD |
TypeScript entry point, BootScene with progress bar, GameScene skeleton |
references/animate-scaffolds.md |
Phase 3 ANIMATE |
Animation definitions, Player state machine, input handling |
references/polish-scaffolds.md |
Phase 4 POLISH |
Camera, particles, tweens, sound, mobile controls, verification |
references/errors.md |
Error Handling |
Common Phaser error scenarios and fixes |
references/arcade-physics.md |
Arcade physics |
Groups, colliders, velocity, physics tuning, pitfalls |
references/tilemaps.md |
Tilemap / Tiled |
Layer system, collision, animated tiles, object layers |
references/spritesheets.md |
Sprites / animation |
Frame measurement, loading, atlases, nine-slice |
references/performance.md |
Performance concern |
Object pooling, GC avoidance, texture atlases, mobile |
references/game-feel-patterns.md |
Polish / juice signal |
Screen shake, particle bursts, hit-stop, scale punch, tween chains, sound timing |
references/tilemaps-and-physics.md |
Complex maps / Matter.js |
Tiled integration pipeline, Matter.js vs Arcade decision table, collision categories, slopes, object layer spawning |
1---2name: phaser-gamedev3description: Phaser 3 2D game dev: scenes, physics, tilemaps, sprites, polish.4---5
6# Phaser Gamedev Skill
7
8## Overview
9
10This skill builds complete Phaser 3 2D games using a **Phased Construction** pattern: DESIGN (plan game type, physics, scenes) → BUILD (scene lifecycle, sprites, tilemaps) → ANIMATE (physics, animation state machines, input) → POLISH (camera effects, particles, tweens, sound, mobile). Targets Phaser 3.60+ throughout.
11
12**Scope**: Platformers, arcade shooters, top-down RPGs, puzzle games, and side-scrollers — anything 2D in Phaser 3. Use `threejs-builder` for 3D games, native mobile games, and non-Phaser canvas work.
13
14---
15
16## Reference Loading Table
17
18| Signal | Load These Files | Why |
19|---|---|---|
20| `references/core-patterns.md` | `core-patterns.md` | Always |
21| `references/build-scaffolds.md` | `build-scaffolds.md` | Phase 2 BUILD |
22| `references/animate-scaffolds.md` | `animate-scaffolds.md` | Phase 3 ANIMATE |
23| `references/polish-scaffolds.md` | `polish-scaffolds.md` | Phase 4 POLISH |
24| `references/errors.md` | `errors.md` | Error Handling |
25| `references/arcade-physics.md` | `arcade-physics.md` | Arcade physics |
26| `references/tilemaps.md` | `tilemaps.md` | Tilemap / Tiled |
27| `references/spritesheets.md` | `spritesheets.md` | Sprites / animation |
28| `references/performance.md` | `performance.md` | Performance concern |
29| `references/game-feel-patterns.md` | `game-feel-patterns.md` | Polish / juice signal |
30| `references/tilemaps-and-physics.md` | `tilemaps-and-physics.md` | Complex maps / Matter.js |
31
32## Instructions
33
34### Phase 1: DESIGN
35
36**Goal**: Understand what to build, select the physics system, and plan the scene graph before writing any code.
37
38**Core constraints**:
39- **Read repository CLAUDE.md before building** — local standards override defaults here
40- **Select physics system before any other decision** — Arcade (fast AABB), Matter.js (complex shapes), or no physics cannot be mixed per scene without deliberate design
41- **Plan scenes upfront** — Boot → Preload → Game → UI is the standard flow; diverge only when the game requires it
42
43**Step 1: Identify the game type**
44
45From the user's request, determine: game genre (platformer, shooter, RPG, puzzle, side-scroller), primary physics need, number of scenes, tilemap or procedural world, spritesheet or texture atlas.
46
47**Step 2: Select the physics system**
48
49| Physics | Use When | When Not to Use |
50|---------|----------|------------|
51| Arcade | Platformers, shooters, simple AABB | Rotating bodies, non-rectangular shapes |
52| Matter.js | Physics puzzles, destructible terrain | Performance-critical (100+ bodies) |
53| None | Puzzles, card games, UI-only | Any meaningful collision detection |
54
55**Step 3: Document the scene plan and load references**
56
57Write a short markdown scene plan covering: Boot, Game, UI, Physics choice, World, Sprites (measured frame dimensions).
58
59Load these references based on the plan:
60- Always: `references/core-patterns.md` (scene lifecycle, transitions, input)
61- If tilemap: `references/tilemaps.md`
62- If sprites/animation: `references/spritesheets.md`
63- If Arcade physics: `references/arcade-physics.md`
64- If performance concern or many moving objects: `references/performance.md`
65- If polish / game feel / juice signal ("screen shake", "particles", "game feel", "hit feedback", "satisfying"): `references/game-feel-patterns.md`
66- If Matter.js, slopes, object layers, complex collision, or enemy spawning from Tiled: `references/tilemaps-and-physics.md`
67
68**Gate**: Scene plan documented. Physics system selected. References loaded. Proceed only when gate passes.
69
70---
71
72### Phase 2: BUILD
73
74**Goal**: Implement the scene lifecycle skeleton, load assets, place sprites, wire up tilemaps.
75
76**Core constraints**:
77- **MEASURE spritesheet frames before loading** — wrong `frameWidth`/`frameHeight` is the #1 Phaser bug; open the PNG, count pixels per frame before writing `this.load.spritesheet()`
78- **Preload all assets in `preload()`** — never load assets in `create()` or `update()`
79- **Use a Boot scene for asset loading** — shows a progress bar, keeps Game scene clean
80
81Full TypeScript scaffolds (entry point, BootScene with progress bar, GameScene skeleton): `references/build-scaffolds.md`.
82
83**Gate**: Boot and Game scenes compile. Assets load without console errors. Scene transitions work. Proceed only when gate passes.
84
85---
86
87### Phase 3: ANIMATE
88
89**Goal**: Add physics-driven movement, animation state machines, and player input.
90
91**Core constraints**:
92- **Never allocate objects in `update()`** — no `new Phaser.Math.Vector2()`, no `this.physics.add.sprite()`, no array creation per frame; allocate in `create()`, reuse in `update()`
93- **Use `delta` for frame-rate-independent movement** — `velocity = speed * (delta / 1000)` ensures consistent feel at any FPS
94- **State machine over boolean flags** — `'idle' | 'walk' | 'jump' | 'attack' | 'dead'` prevents impossible states like `isJumping && isAttacking`
95
96Animation definitions (`anims.create`), the Player state machine, and input handling scaffolds: `references/animate-scaffolds.md`. Collision groups, overlap callbacks, and physics tuning: `references/arcade-physics.md`.
97
98**Gate**: Player moves. Animations transition correctly. State machine has no impossible state combinations. No per-frame allocations. Proceed only when gate passes.
99
100---
101
102### Phase 4: POLISH
103
104**Goal**: Add camera work, particles, tweens, sound, and mobile controls. Verify performance.
105
106**Core constraints**:
107- **Remove `debug: true` from physics config** before shipping
108- **Remove all `console.log` calls** unless the user explicitly requested logging
109- **Test on a 60 FPS budget** — Arcade + 200 active bodies + 50 particles is the practical ceiling on mid-range mobile
110
111Full scaffolds for camera effects, particles (Phaser 3.60+ API), tweens, sound, mobile virtual controls, and final verification steps: `references/polish-scaffolds.md`.
112
113**Gate**: Polish checks pass. Performance within budget. Debug config removed. Game is shippable.
114
115---
116
117## Error Handling
118
119Common errors and fixes (spritesheet frame mismatches, undefined body access, tilemap collision no-ops, animation failures, mobile slowdowns): `references/errors.md`.
120
121---
122
123## References
124
125| Reference | When to Load | Content |
126|-----------|-------------|---------|
127| `references/core-patterns.md` | Always | Scene lifecycle, transitions, input, state machines |
128| `references/build-scaffolds.md` | Phase 2 BUILD | TypeScript entry point, BootScene with progress bar, GameScene skeleton |
129| `references/animate-scaffolds.md` | Phase 3 ANIMATE | Animation definitions, Player state machine, input handling |
130| `references/polish-scaffolds.md` | Phase 4 POLISH | Camera, particles, tweens, sound, mobile controls, verification |
131| `references/errors.md` | Error Handling | Common Phaser error scenarios and fixes |
132| `references/arcade-physics.md` | Arcade physics | Groups, colliders, velocity, physics tuning, pitfalls |
133| `references/tilemaps.md` | Tilemap / Tiled | Layer system, collision, animated tiles, object layers |
134| `references/spritesheets.md` | Sprites / animation | Frame measurement, loading, atlases, nine-slice |
135| `references/performance.md` | Performance concern | Object pooling, GC avoidance, texture atlases, mobile |
136| `references/game-feel-patterns.md` | Polish / juice signal | Screen shake, particle bursts, hit-stop, scale punch, tween chains, sound timing |
137| `references/tilemaps-and-physics.md` | Complex maps / Matter.js | Tiled integration pipeline, Matter.js vs Arcade decision table, collision categories, slopes, object layer spawning |