scenes
БесплатноБез исполняемых скриптовНе проверенUse this skill when working with Phaser 4 scenes. Covers scene lifecycle methods, scene transitions, parallel scenes, scene communication, sleeping, pausing…
от phaserjs★ 40 842 звезды на GitHubОб этом скилле
Scenes
Scenes are the organizational backbone of a Phaser game. Each Scene has its own lifecycle (init, preload, create, update), its own set of injected systems (this.add, this.input, this.cameras, etc.), and can be started, stopped, paused, slept, or run in parallel with other Scenes. The ScenePlugin (
this.scene) controls all multi-scene orchestration.
Key source paths: src/scene/Scene.js, src/scene/Systems.js, src/scene/SceneManager.js, src/scene/ScenePlugin.js, src/scene/Settings.js, src/scene/const.js, src/scene/events/, src/scene/InjectionMap.js
Related skills: ../game-setup-and-config/SKILL.md, ../loading-assets/SKILL.md, ../events-system/SKILL.md
Quick Start
// Minimal scene with all lifecycle methods
class GameScene extends Phaser.Scene {
constructor() {
super('GameScene');
}
init(data) {
// Called first. Receives data passed from other scenes.
// 'data' is whatever was passed via scene.start('GameScene', { level: 1 })
this.level = data.level || 1;
}
preload() {
// Called after init. Load assets here.
this.load.image('logo', 'assets/logo.png');
}
create(data) {
// Called after preload completes. Set up game objects.
// 'data' is the same object passed to init.
this.add.image(400, 300, 'logo');
}
update(time, delta) {
// Called every frame while scene is RUNNING.
// time: current time (ms), delta: ms since last frame (smoothed)
}
}
const config = {
width: 800,
height: 600,
scene: [GameScene]
};
const game = new Phaser.Game(config);
Core Concepts
Scene Lifecycle
The lifecycle is driven by SceneManager.bootScene() and SceneManager.create():
- PENDING (0) - Scene is registered but not yet started.
- INIT (1) -
scene.init(data)is called if defined. Data comes fromsettings.data. - START (2) -
Systems.start()fires. Eventsstartandreadyare emitted. - LOADING (3) -
scene.preload()is called if defined. Loader runs. On completion, proceeds to create. - CREATING (4) -
scene.create(data)is called if defined. Samedataas init. - RUNNING (5) -
scene.update(time, delta)called every frame. Scene renders. - PAUSED (6) - No update, but still renders.
- SLEEPING (7) - No update, no render. State preserved in memory.
- SHUTDOWN (8) - Scene is shut down, systems emit
shutdown. Can be restarted. - DESTROYED (9) - Scene is fully destroyed. Cannot be restarted.
State constants are on Phaser.Scenes: Phaser.Scenes.PENDING, Phaser.Scenes.RUNNING, etc.
Flow when no preload exists: init() -> create() -> update() loop (preload is skipped entirely).
Flow with preload: init() -> preload() -> loader runs -> create() -> update() loop.
Scene-Injected Properties
These properties are injected into every Scene instance via the InjectionMap (src/scene/InjectionMap.js). The left side is the Systems key, the right is the Scene property name.
Global Managers (shared across all scenes)
| Scene Property | Type | Description |
|---|---|---|
this.game |
Phaser.Game |
The Game instance |
this.renderer |
CanvasRenderer | WebGLRenderer |
The active renderer |
this.anims |
Phaser.Animations.AnimationManager |
Global animation manager |
this.cache |
Phaser.Cache.CacheManager |
Global cache for non-image assets |
this.plugins |
Phaser.Plugins.PluginManager |
Global plugin manager |
this.registry |
Phaser.Data.DataManager |
Global data manager (shared between scenes) |
this.scale |
Phaser.Scale.ScaleManager |
Global scale manager |
this.sound |
NoAudio | HTML5Audio | WebAudioSoundManager |
Sound manager |
this.textures |
Phaser.Textures.TextureManager |
Global texture manager |
Scene-Specific Systems (unique per scene)
| Scene Property | Type | Description |
|---|---|---|
this.sys |
Phaser.Scenes.Systems |
Scene systems (never overwrite) |
this.events |
Phaser.Events.EventEmitter |
Scene-specific event emitter |
this.cameras |
Phaser.Cameras.Scene2D.CameraManager |
Scene camera manager |
this.add |
Phaser.GameObjects.GameObjectFactory |
Factory: creates and adds to display list |
this.make |
Phaser.GameObjects.GameObjectCreator |
Creator: creates but does NOT add to display list |
this.scene |
Phaser.Scenes.ScenePlugin |
Scene manager plugin (start/stop/launch) |
this.children |
Phaser.GameObjects.DisplayList |
The scene display list |
this.lights |
Phaser.GameObjects.LightsManager |
Scene lights (plugin) |
this.data |
Phaser.Data.DataManager |
Scene-specific data manager |
this.input |
Phaser.Input.InputPlugin |
Scene input manager (plugin) |
this.load |
Phaser.Loader.LoaderPlugin |
Scene loader (plugin) |
this.time |
Phaser.Time.Clock |
Scene time/clock (plugin) |
this.tweens |
`Phas |
Установить scenes в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл scenes?
Use this skill when working with Phaser 4 scenes. Covers scene lifecycle methods, scene transitions, parallel scenes, scene communication, sleeping, pausing, restarting, and the SceneManager. Triggers on: Scene, scene lifecycle, preload, create, update, scene transition, SceneManager.
Как установить скилл scenes?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл scenes запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic