scenes

Implements Phaser 4 scene lifecycle management, transitions, and multi-scene orchestration.

Updated May 7, 2021
One-click install
npx skills add https://github.com/travispwingo/travispwingo.github.io --skill scenes-travispwingo
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: scenes
Source: https://github.com/travispwingo/travispwingo.github.io/tree/main/mario/docs/skills/scenes
Command: npx skills add https://github.com/travispwingo/travispwingo.github.io --skill scenes-travispwingo

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Phaser games are organized around scenes, but managing their lifecycle states, transitions, parallel execution, and cross-scene communication involves many subtle rules that are easy to get wrong, such as queued operations and shutdown versus sleep semantics. ## Core Features & Use Cases - Lifecycle Management: Covers init, preload, create, and update methods plus all ten scene states from PENDING to DESTROYED. - Scene Orchestration: Explains start, switch, launch, run, pause, sleep, wake, and animated transitions via the ScenePlugin. - Data and Event Communication: Documents six patterns for passing data between scenes, including the global registry and cross-scene event emitters. - Use Case: Build a game with a GameScene and a parallel UIScene that displays a live score by listening to events emitted from the game scene. ## Quick Start Ask the AI to create a Phaser scene with init, preload, create, and update methods and show how to transition to a second scene with a score value.

Frequently Asked Questions about scenes

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

FAQPage Schema
How do I switch between scenes in Phaser?▼

Use this.scene.start('Key', data) to shut down the current scene and start the target, or this.scene.switch('Key') to sleep the current scene while preserving its state. For animated transitions, use this.scene.transition with a duration and target config.

How do I run multiple Phaser scenes in parallel?▼

Use this.scene.launch('Key') to start another scene without stopping the current one, or this.scene.run('Key') which starts, resumes, or wakes the target as needed. Control render order with bringToTop, sendToBack, moveAbove, and moveBelow.

How do I pass data between Phaser scenes?▼

Pass a data object to start, launch, or switch and read it in init(data) and create(data). For ongoing sharing, use the global this.registry across all scenes, the scene-specific this.data manager, or emit events on another scene's EventEmitter.

What is the difference between pause, sleep, and stop in Phaser scenes?▼

Pause stops the update loop but still renders the scene. Sleep stops both update and rendering while preserving state in memory. Stop performs a full shutdown, clearing the display list and timers, but the scene can be restarted.

Why does my Phaser scene state not reset on restart?▼

The scene constructor runs only once, so state set there persists across restarts. Reset state in init(), which runs every time the scene starts, and clean up stale object references by listening to the shutdown event.

Why does this.scene.start not take effect immediately in Phaser?▼

All ScenePlugin methods are queued and execute on the next SceneManager update, not synchronously. Do not rely on the target scene's state within the same frame that you call start, launch, or stop.