events-system

Centralize Phaser 4 events through EventEmitter with on/once/off and emit.

40.1k|7.2k|Updated Apr 12, 2013
One-click install
npx skills add https://github.com/phaserjs/phaser --skill events-system-phaserjs
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: events-system
Source: https://github.com/phaserjs/phaser/tree/main/skills/events-system
Command: npx skills add https://github.com/phaserjs/phaser --skill events-system-phaserjs

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Phaser's event system centralizes communication across all major subsystems (Game, Scene, Input, Loader, Cameras, Sound, Tweens, Physics, Textures, Animations), enabling decoupled coordination through EventEmitter patterns and consistent keys.

Core Features & Use Cases

  • EventEmitter backbone shared across systems, with on/once/off and emit semantics.
  • Scene vs Game level event buses and inter-scene messaging and global events.
  • Custom events and listener wiring to coordinate gameplay logic, UI updates, and lifecycle flows.

Quick Start

Listen to a scene event and emit a custom event to coordinate gameplay logic.

Frequently Asked Questions about events-system

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

FAQPage Schema
How do I coordinate inter-scene messaging in Phaser 4?

Inter-scene messaging in Phaser 4 is coordinated by centralizing communication through dedicated EventEmitter abstractions, separating scene-level and game-level events to decouple systems. This enables consistent cross-system coordination using on, once, off, and emit semantics.

What is the difference between scene events and game events in Phaser?

Scene events in Phaser handle lifecycle flows and gameplay logic within a specific scene, while game events act as a global bus for inter-scene messaging and broader system coordination. Separating them decouples UI components from core game flow.

How do I listen to and emit custom events for Phaser gameplay logic?

To handle custom events for Phaser gameplay logic, use the shared EventEmitter backbone with standard on, once, off, and emit semantics. This wires listener logic to coordinate UI updates, scene lifecycles, and game flow.

Does Phaser's event system support decoupled communication across input and physics subsystems?

Yes, Phaser's event system supports decoupled communication across major subsystems including Input, Physics, Cameras, Sound, and Tweens. It uses consistent event keys and an EventEmitter pattern to coordinate these systems without direct dependencies.

What's the best way to structure event namespaces for Phaser game events?

The best way to structure event namespaces for Phaser game events is by centralizing them through constants. Using dedicated EventEmitter abstractions with consistent keys ensures maintainable listener wiring across Game, Scene, and UI components.

When do I need a dedicated EventEmitter abstraction in Phaser?

A dedicated EventEmitter abstraction in Phaser is needed when coordinating complex game flow, scene lifecycles, or inter-scene messaging. It provides a centralized backbone for custom events, preventing tightly coupled logic across Game and Scene systems.