events-system

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

Updated Apr 13, 2026
One-click install
npx skills add https://github.com/onemanking/the-operator --skill events-system-onemanking
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: events-system
Source: https://github.com/onemanking/the-operator/tree/main/.github/skills/events-system
Command: npx skills add https://github.com/onemanking/the-operator --skill events-system-onemanking

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Phaser's event system spans dozens of namespaces and emitters, making it easy to mistype event strings, leak listeners across scene restarts, or confuse scene-level and game-level emitters. This Skill provides a complete reference for wiring up events correctly. ## Core Features & Use Cases - Full EventEmitter API: Covers on, once, off, emit, removeAllListeners, and context binding inherited from eventemitter3. - Complete Event Reference: Documents every built-in event constant across Scene, Game, Input, Loader, Animation, Camera, Sound, Tween, Physics, Texture, GameObject, and Time namespaces. - Memory Leak Prevention: Shows shutdown cleanup patterns so listeners do not accumulate when scenes restart. - Use Case: When building a Phaser game where a UI scene must react to score changes in a gameplay scene, use this Skill to set up communication via game.events or the registry without leaking listeners on scene restart. ## Quick Start Ask the AI to show how to listen for a pointer down event and emit a custom event in a Phaser scene with proper cleanup on 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.input.on('pointerdown', handler) or this.events.on(Phaser.Scenes.Events.UPDATE, handler, this). Prefer named constants like Phaser.Scenes.Events.UPDATE over raw strings to avoid typos.

How do I communicate between scenes in Phaser?

Use this.game.events as a global event bus, the shared this.registry DataManager with changedata events, or direct scene access via this.scene.get('SceneKey').events. Each approach lets one scene emit events that another scene listens to.

Why do Phaser event listeners duplicate after scene restart?

Listeners registered with on() persist when a scene restarts, so each restart adds duplicates. Clean them up by calling off() inside a SHUTDOWN handler, or use once() for single-fire listeners.

What is the difference between this.events and this.game.events in Phaser?

this.events is scene-specific and cleaned up when the scene is destroyed, while this.game.events is global and persists across scene restarts. Listeners on game.events must be manually removed on scene shutdown.

Why does off() not remove my Phaser event listener?

off() only works when you pass the exact same function reference and context used with on(). Anonymous or inline arrow functions cannot be removed, so store a named method reference instead.