data-manager

Manage key-value game state with Phaser DataManager events.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It helps you manage and synchronize custom game state by storing key-value data on game objects, scenes, and the global registry while reacting to changes through events instead of tightly coupling systems.

Core Features & Use Cases

  • Per-GameObject data: Use Phaser DataManager via sprite.setData/getData/incData/toggleData to attach state directly to entities and listen to events like changedata-hp.
  • Scene-level data: Use this.data as a DataManagerPlugin for scene-specific state that integrates with the scene event bus.
  • Global registry state: Use game.registry (this.registry in scenes) for cross-scene values that persist for the lifetime of the Game.
  • Event-driven updates: React to setdata, changedata, changedata-{key}, and removedata with the correct callback signatures depending on where the DataManager lives.
  • Practical use case: Keep a score in the GameScene and have a HUD scene automatically update its UI by listening to registry changedata-score events, while ensuring listeners are removed on shutdown to avoid stale updates.

Quick Start

Use the data-manager skill to set and update a sprite’s hp with sprite.setData('hp', 100) and then listen for sprite.on('changedata-hp', ...) to drive health UI and destruction logic.

Frequently Asked Questions about data-manager

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

FAQPage Schema
How do I share game state between multiple Phaser scenes?

To share game state across Phaser scenes, store key-value data in the global game registry using `this.registry.set()` so values persist for the lifetime of the game and remain accessible from any active scene.

How do I track score changes in Phaser without tightly coupling my UI?

Track score changes reactively by storing the value with `setData` and subscribing to `changedata-score` events, allowing a HUD scene to listen and update automatically when the score mutates.

Does Phaser DataManager automatically emit events when I modify an object inside a stored array?

Phaser DataManager does not automatically emit change events when you mutate an object or array in place; you must re-set the key using the `set` API to trigger the `changedata` event and notify listeners.

What is the difference between scene-level data and global registry data in Phaser?

Scene-level data uses the `DataManagerPlugin` for state isolated to that specific scene's event bus, while the global registry stores cross-scene values that persist throughout the entire game lifecycle.

How do I increment or toggle boolean flags on a Phaser game object?

Increment or toggle flags on Phaser game objects using the `incData` and `toggleData` APIs, which update the stored key-value state and automatically fire the corresponding `changedata` events.

Why are my Phaser data listeners firing on stale scenes after shutdown?

Stale data listeners fire when event subscriptions are not removed during scene shutdown; you must detach `changedata` and `setdata` listeners on the registry or game objects when the listening scene is destroyed.