원클릭으로
phaser-gamedev
// Build 2D browser games with Phaser 3: scene lifecycle, sprites/animations, input, Arcade/Matter physics, tilemaps, performance, and game architecture.
// Build 2D browser games with Phaser 3: scene lifecycle, sprites/animations, input, Arcade/Matter physics, tilemaps, performance, and game architecture.
| name | phaser-gamedev |
| description | Build 2D browser games with Phaser 3: scene lifecycle, sprites/animations, input, Arcade/Matter physics, tilemaps, performance, and game architecture. |
| metadata | {"short-description":"Phaser 3 game dev (scenes, sprites, physics, tilemaps)."} |
Build 2D browser games using Phaser 3's scene-based architecture and physics systems.
Phaser will happily render something even when asset metadata is wrong—so many mistakes show up as “mystery glitches” later. Prefer workflows that make correctness obvious early:
Before coding, ask:
Read references/spritesheets-nineslice.md first.
Spritesheet loading is fragile—a few pixels off causes silent corruption that compounds into broken visuals. The reference file contains the inspection protocol and the spacing/margin math.
NEVER guess frame dimensions. DO NOT “eyeball” spacing or assume square vs non-square without measuring.
Read these before working on the relevant feature:
| When working on... | Read first |
|---|---|
| Loading any spritesheet | references/spritesheets-nineslice.md |
| Nine-slice UI panels | references/spritesheets-nineslice.md |
| Tiled tilemaps, collision layers | references/tilemaps.md |
| Physics tuning, groups, pooling | references/arcade-physics.md |
| Performance issues, object pooling | references/performance.md |
| System | Use when |
|---|---|
| Arcade | Platformers, shooters, most 2D games (fast AABB collisions) |
| Matter | Physics puzzles, ragdolls, more realistic collisions (slower, more accurate) |
| None | Menu scenes, visual novels, card games |
scenes/
├── BootScene.ts # Asset loading, progress bar
├── MenuScene.ts # Title screen, options
├── GameScene.ts # Main gameplay
├── UIScene.ts # HUD overlay (launched parallel)
└── GameOverScene.ts # End screen, restart
this.scene.start('GameScene', { level: 1 }); // Stop current, start new
this.scene.launch('UIScene'); // Run in parallel
this.scene.pause('GameScene'); // Pause
this.scene.stop('UIScene'); // Stop
const config: Phaser.Types.Core.GameConfig = {
type: Phaser.AUTO,
width: 800,
height: 600,
scale: {
mode: Phaser.Scale.FIT,
autoCenter: Phaser.Scale.CENTER_BOTH
},
physics: {
default: 'arcade',
arcade: { gravity: { y: 300 }, debug: false }
},
scene: [BootScene, MenuScene, GameScene]
};
class GameScene extends Phaser.Scene {
init(data: unknown) {} // Receive data from previous scene
preload() {} // Load assets (runs before create)
create() {} // Set up game objects, physics, input
update(time: number, delta: number) {} // Game loop; use delta for frame-rate independence
}
// Correct: scales with frame rate
this.player.x += this.speed * (delta / 1000);
// Wrong: varies with frame rate
this.player.x += this.speed;
| Anti-pattern | Why it hurts | Better |
|---|---|---|
Global state on window | Scene transitions break state | Use scene data, registries, or a game-state module |
Loading in create() | Assets may be referenced before ready | Load in preload(), or centralize loading in Boot |
| Frame counting | Game speed varies with FPS | Use delta / 1000 |
| Matter for simple collisions | Unnecessary complexity | Arcade handles most 2D games |
| One giant scene | Hard to extend and debug | Separate gameplay/UI/menus |
| Magic numbers everywhere | Impossible to balance | Central config objects/constants |
| No pooling for churny objects | GC stutters | Reuse with groups + setActive(false) |
Common pitfall: “it looks fine at 60fps” — test at variable frame rates and on low-power devices.
Avoid converging on a single “favorite” Phaser setup. Choose based on context:
UIScene vs in-scene HUD.Phaser provides powerful primitives—scenes, sprites, physics, input—but architecture is your responsibility.
Before coding: what scenes exist, what entities live where, and how they communicate.
Codex is capable of extraordinary Phaser work: it can unlock creative solutions, explore alternatives, and push boundaries when you provide clear constraints and a solid source of truth. These guidelines illuminate the path—they don't fence it.
Build 2D browser games with Phaser 4: WebGL-first rendering, scenes, filters, lighting, shaders, DynamicTexture and RenderTexture, tilemaps, SpriteGPULayer, TilemapGPULayer, and Phaser 3 to 4 migration work.
Build 2D games with Phaser 3 framework. Covers scene lifecycle, sprites, physics (Arcade/Matter), tilemaps, animations, input handling, and game architecture. Trigger: "create phaser game", "add phaser scene", "phaser sprite", "phaser physics", "game development with phaser".