data-manager

Manage key-value game state with Phaser DataManager events across objects, scenes, and registry.

Updated Jun 10, 2026
One-click install
npx skills add https://github.com/mudman1986/quarterless --skill data-manager-mudman1986
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: data-manager
Source: https://github.com/mudman1986/quarterless/tree/main/.github/skills/data-manager
Command: npx skills add https://github.com/mudman1986/quarterless --skill data-manager-mudman1986

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Storing and synchronizing custom game state in Phaser 4 often leads to tightly coupled code and missed updates. This Skill explains how to use the DataManager to attach reactive key-value data to game objects, scenes, and the global registry with event-driven change tracking. ## Core Features & Use Cases - Three-Level Data Storage: Use per-GameObject data (setData/getData), per-Scene data (this.data), and the global registry (this.registry) for cross-scene state. - Event-Driven Reactivity: Listen to setdata, changedata, changedata-{key}, and removedata events to update HUDs, health bars, and UI without polling. - Helpers and Patterns: Covers inc/toggle/merge/query/freeze operations plus persistence patterns like saving scene data to localStorage. - Use Case: Build a HUD scene that watches registry score changes from the game scene, updating the score display automatically whenever the value changes. ## 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 setData(key, value) on any GameObject, which lazily creates a DataManager on first use. Retrieve values with getData(key), and use incData or toggleData for numeric and boolean updates.

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. Other scenes read it with this.registry.get(key) and listen for changes on this.registry.events.

What is the difference between Phaser this.data and this.registry?

this.data is a per-scene DataManagerPlugin emitting events on the scene's event bus, while this.registry is a global DataManager on the Game object shared across all scenes with its own event emitter.

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

Mutating a stored object or array in place does not change its reference, so no changedata event fires. Re-set the key with a new reference, such as setData('inventory', [...inv]), to trigger the event.

Do registry event listeners persist after a Phaser scene restarts?

Yes, listeners on this.registry.events survive scene restarts because the registry lives on the Game object. Remove them in a shutdown handler with this.events.once('shutdown', ...) to avoid duplicate handlers.