events-system

Implement Phaser EventEmitter communication with named constants and listener cleanup.

Updated Feb 11, 2026
One-click install
npx skills add https://github.com/ArtRiv/game-topicos-especiais --skill events-system-artriv
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: events-system
Source: https://github.com/ArtRiv/game-topicos-especiais/tree/main/skills/events-system
Command: npx skills add https://github.com/ArtRiv/game-topicos-especiais --skill events-system-artriv

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Managing Phaser’s event-driven architecture can get messy, especially when mixing Scene lifecycle events, game-level events, input events, and custom events without creating memory leaks.

Core Features & Use Cases

  • Phaser EventEmitter fundamentals: Learn how Phaser’s EventEmitter (eventemitter3) supports on, once, off, emit, and cleanup via shutdown/destroy.
  • Scene vs game event communication: Use this.events for scene lifecycle and this.game.events as a global event bus across scenes.
  • Typed safety via named constants: Prefer Phaser-provided event constants to avoid typo-prone lowercase strings and improve editor autocomplete.
  • Practical use cases: Update HUDs from gameplay changes, coordinate inter-scene communication, and prevent duplicated listeners on scene restarts by cleaning up on shutdown.

Quick Start

Use the events-system skill to correctly register and remove Phaser event listeners in a Scene using named constants, including firing and handling a custom event like player-died.

Frequently Asked Questions about events-system

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

FAQPage Schema
How do I prevent memory leaks when using Phaser EventEmitter across scenes?

Preventing Phaser EventEmitter memory leaks requires removing listeners on the SHUTDOWN event using consistent function references with off or removeAllListeners. This cleanup stops duplicated listeners from accumulating after scene restarts.

How does Phaser scene event communication work between active scenes?

Phaser scene event communication uses this.events for local scene lifecycle updates and this.game.events as a global event bus across scenes. This enables emitting custom events and subscribing to coordinate inter-scene UI updates and gameplay changes.

Should I use Phaser named event constants or lowercase strings for event keys?

Using Phaser named event constants instead of lowercase strings improves editor autocomplete and avoids typo-prone event keys. Typed safety via named constants ensures reliable event-driven communication across the game's core subsystems.

How do I update the HUD from gameplay changes in Phaser?

Updating the HUD from gameplay changes in Phaser involves emitting custom events from gameplay logic and subscribing to them within the UI scene. Use the global game event bus or scene events to wire these inter-scene UI updates safely.

Why are my Phaser event listeners firing multiple times after a scene restart?

Phaser event listeners fire multiple times after a scene restart because previous listeners were not removed on SHUTDOWN. You must clean up listeners using off or removeAllListeners with the exact same function references to prevent duplication.