events-system

Implements event-driven communication in Phaser 4 using EventEmitter, scene events, and named constants.

465|41|Updated Aug 4, 2026
One-click install
npx skills add https://github.com/autonomous-ai/openharness --skill events-system-autonomous-ai
Or copy as Structured Prompt for Agentā–¼
Please help me install this Agent Skill.
Skill: events-system
Source: https://github.com/autonomous-ai/openharness/tree/main/store/agents/phaser/skills/events-system
Command: npx skills add https://github.com/autonomous-ai/openharness --skill events-system-autonomous-ai

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Phaser 4 games rely on an EventEmitter pattern spread across many subsystems, and developers often struggle to know which events exist, which emitter fires them, and how to avoid memory leaks from unremoved listeners. This Skill provides a complete reference and usage patterns for the entire Phaser event system. ## Core Features & Use Cases - Full EventEmitter API coverage: Documents on, once, off, emit, removeAllListeners, and context binding inherited from eventemitter3. - Complete event namespace reference: Lists every built-in event constant and string for scenes, game, input, loader, animations, cameras, sound, tweens, physics, textures, GameObjects, and timers. - Inter-scene communication patterns: Shows three methods for sharing data between scenes using game.events, the registry DataManager, and direct scene access. - Use Case: When building a game where a UI scene must react to score changes in a gameplay scene, use this Skill to wire up a custom event on game.events and clean it up correctly on scene shutdown to prevent duplicate listeners after restarts. ## Quick Start Ask the AI to set up a Phaser scene that listens for pointer input and emits a custom event, with proper listener cleanup on scene shutdown.

Frequently Asked Questions about events-system

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

FAQPage Schema
How do I listen for events in Phaser?ā–¼

Use the on() method on any Phaser emitter, such as this.events for scene events or this.input for pointer events. Pass the event name or constant, a callback function, and optionally a context as the third argument to set this inside the handler.

How do scenes communicate with each other in Phaser?ā–¼

Scenes communicate through three methods: emitting custom events on the shared this.game.events bus, setting values in this.registry and listening for changedata events, or directly accessing another scene via this.scene.get() and emitting on its events emitter.

Why do Phaser event listeners fire multiple times after scene restart?ā–¼

Listeners registered with on() persist across scene restarts because shutdown does not auto-remove them, so each restart adds duplicates. Fix this by removing listeners in a SHUTDOWN handler using off() with the exact same function reference and context.

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

Scene events on this.events are scene-specific and fire lifecycle events like update and shutdown, while game events on this.game.events are global and fire game-level events like blur and focus. Game event listeners persist across scene restarts and need manual cleanup.

Can I remove an anonymous arrow function listener in Phaser?ā–¼

No, off() requires the exact same function reference passed to on(), so anonymous or inline arrow functions cannot be removed. Use a named class method or store the function reference, or use once() if the listener only needs to fire a single time.