What problem does it solve?
It prevents brittle, error-prone gameplay flow by showing how to correctly listen to, emit, and clean up Phaser 4 events across Game, Scene, Input, Loader, Tweens, Physics, and more.
Core Features & Use Cases
- EventEmitter-driven communication: Use
on, once, off, emit, and removeAllListeners to build decoupled, event-driven gameplay.
- Lifecycle-safe listener management: Clean up scene listeners on
SHUTDOWN to avoid duplicate handlers and memory leaks on scene restart.
- Typed, autocomplete-friendly constants: Prefer Phaser event constants (e.g.,
Phaser.Scenes.Events.UPDATE, Phaser.Input.Events.POINTER_DOWN) over raw strings to reduce typos.
- Multi-scope event routing: Handle scene events via
this.events, game-wide events via this.game.events, and emitter-specific events like this.input, this.load, this.anims, and this.physics.world.
Quick Start
Use the events-system skill to wire a pointer-down handler and a scene-shutdown cleanup so you safely emit and respond to custom events like player-died.