data-manager

Stores key-value data on Phaser game objects with event-driven change tracking.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Managing game state across Phaser game objects, scenes, and the global registry often leads to tightly coupled code and missed state updates. This Skill provides guidance on using Phaser's DataManager to store custom key-value data with automatic change events, enabling reactive data binding between game systems. ## Core Features & Use Cases - Three-Level Data Storage: Store data per-GameObject (setData/getData), per-Scene (this.data), or globally across all scenes (this.registry). - Event-Driven Updates: Listen to setdata, changedata, changedata-{key}, and removedata events to react to state changes without polling. - Helper Operations: Use inc, toggle, merge, query, pop, and freeze for common state manipulation patterns. - Use Case: Build a HUD that automatically updates when the player's score changes by listening to changedata-score on the global registry, with proper listener cleanup on scene shutdown. ## Quick Start Show me how to store player health on a Phaser sprite and update a health bar whenever the value changes.

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('key'), or pass an array of keys to get multiple values at once.

How to share data between Phaser scenes?

Use the global registry via this.registry.set('key', value), which persists across all scenes 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 shared across all scenes with its own event emitter. Use scene data for local state and the registry for cross-scene state.

Why does changing an object in Phaser DataManager not trigger changedata?

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

Do Phaser registry listeners persist after scene restart?

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 prevent duplicate handlers and memory leaks.