phaser-design-patterns

Implements creational, structural, and behavioral design patterns in Phaser 3 JavaScript games.

1|Updated Mar 19, 2026
One-click install
npx skills add https://github.com/fiando/bake-tycoon --skill phaser-design-patterns-fiando
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: phaser-design-patterns
Source: https://github.com/fiando/bake-tycoon/tree/main/.github/skills/phaser-design-patterns
Command: npx skills add https://github.com/fiando/bake-tycoon --skill phaser-design-patterns-fiando

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Applying classic design patterns to Phaser 3 games is hard because generic examples ignore scene architecture, physics, input, and performance constraints, leading to coupled code and memory leaks. ## Core Features & Use Cases - Pattern Selection Guidance: Maps real gameplay problems (entity creation, AI behavior, event decoupling) to the right pattern such as Factory, State, Observer, or Command. - Phaser-Native Implementation: Translates patterns into Phaser primitives like Scene, GameObject, Group, Events, Physics, and Input with JavaScript snippets. - Runtime Validation Rules: Enforces event unsubscription in shutdown/destroy, delta-based updates, and object pooling for bullets and particles. - Use Case: When refactoring a Phaser game where enemy AI logic is tangled in update loops, use this Skill to apply the State pattern with a full Idle/Move/Action StateMachine implementation. ## Quick Start Ask the AI to refactor your Phaser 3 enemy behavior code using the State design pattern with proper event cleanup.

Frequently Asked Questions about phaser-design-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement design patterns in Phaser 3?▼

Identify a real gameplay problem first, then map a pattern to Phaser primitives like Scene, GameObject, Group, Events, and Physics. For example, use Factory for variable entity creation and State for AI behavior modes, implementing them in JavaScript with game-domain naming.

Which design pattern should I use for Phaser game entities?▼

Use Factory Method or Abstract Factory for variable entity creation, Flyweight with pooling for thousands of shared instances like bullets, and Builder for step-by-step level or UI construction. Choose based on the coupling problem you need to solve.

How do I prevent memory leaks in Phaser event systems?▼

Unsubscribe all event listeners in the scene's shutdown or destroy methods to avoid leaks. When using Observer or Mediator patterns for gameplay-to-UI communication, always pair subscriptions with cleanup during scene lifecycle transitions.

Does the State pattern work with Phaser physics and update loops?▼

Yes, implement State and StateMachine classes that receive delta time in update(time, delta) for movement and timers. The skill includes a full Idle/Move/Action StateMachine reference implementation adapted to Phaser's scene lifecycle.

When should I avoid singletons in Phaser game code?▼

Avoid mutable singletons for gameplay logic since they create hidden coupling and testing problems. Reserve them only for global services like audio managers or configuration, and prefer composition over deep inheritance hierarchies.