events-system

Implements event-driven communication using Phaser 4 EventEmitter, scene events, and game events.

Updated Sep 20, 2026
One-click install
npx skills add https://github.com/AmirOssanloo/helix-game --skill events-system-amirossanloo
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: events-system
Source: https://github.com/AmirOssanloo/helix-game/tree/main/.claude/skills/events-system
Command: npx skills add https://github.com/AmirOssanloo/helix-game --skill events-system-amirossanloo

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Phaser 4 games rely on the EventEmitter pattern across every major system, and developers often struggle with choosing the right event namespace, avoiding typos in event strings, and preventing memory leaks from unremoved listeners on scene restarts. ## Core Features & Use Cases - Complete Event Reference: Covers all Phaser event namespaces including Scene, Core, Input, Loader, Animations, Cameras, Sound, Tweens, Arcade Physics, Textures, GameObjects, and Time events with constant-to-string mappings. - Listener Lifecycle Management: Documents on, once, off, emit, and removeAllListeners patterns with context binding rules and cleanup strategies for scene shutdown. - Inter-Scene Communication: Explains three methods for cross-scene messaging using game.events as a global bus, the registry DataManager, and direct scene access via ScenePlugin. - Use Case: When building a game where a UI scene must react to score changes in a gameplay scene, use this Skill to correctly emit 'score-changed' on game.events and clean up listeners on SHUTDOWN to avoid duplicate handlers after scene restarts. ## Quick Start Ask the AI to show how to listen for a pointer down event in a Phaser scene and properly remove the listener when the scene shuts down.

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 4?▼

Use the on method on any Phaser EventEmitter, such as this.input.on('pointerdown', handler) or this.events.on(Phaser.Scenes.Events.UPDATE, handler, this). Prefer named constants over raw strings to prevent typos and enable IDE autocomplete.

How to communicate between scenes in Phaser?▼

Phaser offers three inter-scene communication methods: emit custom events on this.game.events as a global bus, use this.registry DataManager with changedata events, or access another scene directly via this.scene.get('SceneName').events.

Why do Phaser event listeners duplicate after scene restart?▼

Listeners registered with on() persist when a scene restarts because they are not auto-removed, 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?▼

this.events is scene-specific, fires scene lifecycle events, and is cleaned up when the scene is destroyed. this.game.events is global, fires game-level events like blur and focus, and persists across scene restarts, requiring manual cleanup.

Can I remove an arrow function event listener in Phaser?▼

No, anonymous or inline arrow functions cannot be removed because off() requires the exact same function reference passed to on(). Store the handler in a variable or use a named class method, or use once() for auto-removal after the first fire.