data-manager

Implements key-value data storage with change events using the Phaser 4 DataManager API.

Updated Jul 13, 2026
One-click install
npx skills add https://github.com/russellmorgan/UnderConstruction --skill data-manager-russellmorgan
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: data-manager
Source: https://github.com/russellmorgan/UnderConstruction/tree/main/.claude/skills/data-manager
Command: npx skills add https://github.com/russellmorgan/UnderConstruction --skill data-manager-russellmorgan

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Managing game state across Phaser 4 game objects, scenes, and the global registry is error-prone when done ad hoc, and developers often miss the event-driven patterns that keep UI and game logic in sync without tight coupling. ## Core Features & Use Cases - Three-Level Data Storage: Covers per-GameObject data (setData/getData), per-Scene data (this.data), and the global registry (this.registry) with correct event emitter routing for each. - Reactive Change Events: Documents setdata, changedata, changedata-{key}, and removedata events so systems like HUDs can react to state changes automatically. - Gotcha Prevention: Explains common pitfalls such as object mutation not firing events, frozen DataManagers failing silently, and registry listeners leaking across scene restarts. - Use Case: Build a HUD scene that watches the global registry for score changes set by the game scene, updating text automatically and cleaning up listeners on shutdown. ## Quick Start Ask the AI to show how to store player health on a sprite with setData and update a health bar whenever the changedata-hp event fires.

Frequently Asked Questions about data-manager

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

FAQPage Schema
How do I store custom data on a Phaser game object?▼

Call sprite.setData('key', value) to store data on any GameObject; the DataManager is created lazily on first use. Retrieve values with getData, increment numbers with incData, and flip booleans with toggleData.

How to share game state between Phaser scenes?▼

Use the global registry via this.registry.set('key', value), which persists for the lifetime of the Game and is accessible from every scene. Listen for changes on this.registry.events, not the scene event bus.

What is the difference between Phaser data, registry, and setData?▼

setData stores data per GameObject, this.data is a per-scene DataManagerPlugin, and this.registry is a global DataManager shared across all scenes. Each emits events on a different emitter: the GameObject, the scene event bus, and registry.events respectively.

Why does changedata not fire when I modify a stored object?▼

Mutating a stored object or array in place does not emit changedata because the reference has not changed. Re-set the key with a new reference, such as setData('inventory', [...inv]), to trigger the event.

Why do my Phaser registry listeners duplicate after scene restart?▼

Registry listeners are not cleaned up when a scene restarts because the registry lives on the Game object. Remove them in a shutdown handler with this.registry.events.off to prevent duplicate handlers.

Can I freeze Phaser data to prevent changes?▼

Yes, set data.freeze = true or call setFreeze(true) to make all set, remove, inc, and toggle operations silently no-op. Note that frozen DataManagers throw no errors, which can make debugging confusing.