phaser-core
FreeNo executable scriptsNot checkedSets up and debugs Phaser 4 games (and pinned Phaser 3.90): Game config, Scene lifecycle, the loader, scene transitions and Phaser 3 to 4 migration. Use when…
by gamedev-skills★ 12,656 GitHub starsAbout this skill
Phaser 4 core
Builds the foundation of a Phaser game: one Phaser.Game, a scene per screen, assets loaded
per scene into a global cache, and a clear split between game rules and the scenes that draw
them. New projects target Phaser 4.2. A project pinned to Phaser 3.90 stays on 3.x unless
the user asks for a migration.
When to use
- Starting a Phaser game, structuring scenes, loading assets, wiring cameras, passing data between scenes, or porting Phaser 3 code to Phaser 4.
- The project has
phaserinpackage.json,import Phaser from 'phaser', or classes that extendPhaser.Scene. - Not for bodies, colliders and movement (
phaser-arcade-physics), Matter.js physics, or engine-neutral menu and HUD design (game-ui-ux; load it next to this skill for UI work).
Workflow
- Read the installed major. Check
package.jsonand the lockfile. Phaser 3 and 4 share the scene model but not the renderer, so a v3 snippet can run and still look wrong in v4. - Keep rules out of scenes. Put state and rules (score, turns, inventory, AI) in plain
modules with no Phaser import. A scene reads that state, draws it, and sends input actions
back. The rules then run under
node --testwithout a browser, and a restart is just new state. - Create one game from a config with
type: Phaser.AUTO, a size, ascalemode and ascenearray. The first scene in the array (and any withactive: true) starts on boot. - One
Scenesubclass per screen with a unique key. Reset run state ininit(), queue assets inpreload(), build objects increate(), step inupdate(time, delta). - Move between screens with the right verb (
start,launch,run,switch,sleep; see Patterns 4) and share data throughthis.registryor a scene'sevents. - Pick where UI lives. A score or health readout fits a parallel HUD scene. Text-heavy
menus and settings work better as HTML over the canvas (
this.add.domor a plain overlay). - Verify with the build and the headless smoke check in Verify.
Patterns
1. Game config and boot
// main.js: one Game owns the renderer, loop, cache and Scene Manager.
import Phaser from 'phaser';
import BootScene from './scenes/BootScene.js';
import PlayScene from './scenes/PlayScene.js';
import HudScene from './scenes/HudScene.js';
const config = {
type: Phaser.AUTO, // WebGL, Canvas only as a fallback
parent: 'game', // id of the element that holds the canvas
width: 800,
height: 600,
backgroundColor: '#1d1d28',
scale: { mode: Phaser.Scale.FIT, autoCenter: Phaser.Scale.CENTER_BOTH },
dom: { createContainer: true }, // only if you use this.add.dom(); needs `parent`
scene: [BootScene, PlayScene, HudScene], // later in the list = drawn on top
};
const game = new Phaser.Game(config);
Object.assign(window, { game }); // for the smoke check and console debugging (TS-safe)
2. A scene with the full lifecycle
// scenes/PlayScene.js
import Phaser from 'phaser';
import { createRun, stepRun } from '../rules/run.js'; // plain module, no Phaser import
export default class PlayScene extends Phaser.Scene {
constructor() {
super('play');
}
init(data) {
this.run = createRun({ level: data.level ?? 1 }); // runs on every (re)start
}
preload() {
this.load.image('player', 'assets/player.png');
this.load.spritesheet('coin', 'assets/coin.png', { frameWidth: 16, frameHeight: 16 });
}
create() {
this.player = this.add.sprite(400, 300, 'player');
this.cursors = this.input.keyboard.createCursorKeys();
if (!this.scene.isActive('hud')) this.scene.launch('hud');
}
update(time, delta) {
const dir = (this.cursors.right.isDown ? 1 : 0) - (this.cursors.left.isDown ? 1 : 0);
stepRun(this.run, { dir }, delta / 1000); // delta is milliseconds
this.player.x = this.run.playerX;
// set() emits changedata-score even when the value is unchanged
if (this.registry.get('score') !== this.run.score) this.registry.set('score', this.run.score);
}
}
3. Cross-scene data and events
// HUD scene: react to registry changes instead of polling every frame.
create() {
this.scoreText = this.add.text(10, 10, 'Score: 0', { fontSize: '20px', color: '#fff' });
const onScore = (_parent, value) => this.scoreText.setText(`Score: ${value}`);
this.registry.events.on('changedata-score', onScore);
// The registry outlives scenes: remove the listener or it stacks on every restart.
this.events.once('shutdown', () => this.registry.events.off('changedata-score', onScore));
}
// Talk to another running scene directly through its event emitter.
this.scene.get('hud').events.emit('show-message', 'Level cleared!');
4. Scene transitions
this.scene.start('gameover', { score }); // stop this scene, start the target
this.scene.launch('hud'); // run in parallel; restarts it if already running
t
Install phaser-core in Claude Code & Claude Desktop
Sign up to install this skill
Create a free account to reveal the install command and save the skill to your library.
- Reveal the one-line install command
- Save skills to your synced library
- Get notified when skills update
Allowed tools
Tools this skill is permitted to call.
No restriction — this skill can use any tool.
Bundled files
FAQ
What does the phaser-core skill do?
Sets up and debugs Phaser 4 games (and pinned Phaser 3.90): Game config, Scene lifecycle, the loader, scene transitions and Phaser 3 to 4 migration. Use when code imports phaser, or on a black screen, assets undefined in create, or a HUD scene behind the game. Not for colliders (`phaser-arcade-physics`), HUD layout (`game-ui-ux`) or PixiJS (`pixijs-rendering`).
How do I install the phaser-core skill?
Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.
Does the phaser-core skill run scripts?
No, this skill is instructions only (SKILL.md) with no executable scripts.
Related skills
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
by Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
by Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
by Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
by Anthropic