Phaser4 Core
Unsigned, install at your own risk
UnverifiedThis skill has no cryptographic signature attached. We can't verify the contents match what the publisher intended.
Install this skill
No account required. Pick your tool, then copy.
Run in your terminal. It detects your AI tool.
npx @skills-hub-ai/cli install phaser-phaser4-coreWhat this does: The rules every piece of Phaser 4 code must follow, and a map of which Phaser skill to load for each task. Use at the start of any Phaser 4 work: making a new game, adding a Scene, porting from Phaser 3, or when unsure which skill applies. Corrects the v3 habits that break v4 code: preFX, postFX, pipelines, setPipeline, BitmapMask, setMask, Geom.Point, Math.PI2, Mesh and Plane don't exist; setTintFill only logs an error; Math.TAU is now 2 PI; the default game size is 1024x768; roundPixels defaults to false; WebGL-only features need a Canvas guard. Triggers on: Phaser, Phaser 4, phaser game, new game, game config, scene, which skill, v3 code in a v4 project.
Manual setup by platform
Claude Code
~/.claude/skills/phaser-phaser4-core/SKILL.md
Instructions
Phaser 4 core rules
The rules which apply to all Phaser 4 code, and which skill to load for each topic. Read this first, then load the skill for the task.
Source: src/phaser.js (the Phaser namespace), src/const.js, src/core/typedefs/GameConfig.js. Types: types/phaser.d.ts. What changed: changelog/v4/. Related: v3-to-v4-migration, v4-new-features.
Quick start
import Phaser from 'phaser';
class Game extends Phaser.Scene
{
constructor ()
{
super('Game');
}
preload ()
{
this.load.image('logo', 'assets/logo.png');
}
create ()
{
const { width, height } = this.scale;
this.add.image(width / 2, height / 2, 'logo');
}
}
new Phaser.Game({
type: Phaser.AUTO,
width: 1024,
height: 768,
parent: 'game',
scene: [ Game ]
});
import Phaser from 'phaser'works from 4.1.import * as Phaser from 'phaser'works too.- From a CDN:
https://cdn.jsdelivr.net/npm/[email protected]/dist/phaser.min.js, which sets thePhaserglobal.
The rules
1. These v3 APIs don't exist in v4
Don't write them, and replace them when porting:
| v3 | v4 |
|---|---|
preFX, postFX, Phaser.FX | Filters: obj.enableFilters(), then obj.filters.internal / obj.filters.external |
setPipeline, pipelines, PostFXPipeline | Render nodes; setLighting(true) for lights |
BitmapMask, setMask, createBitmapMask | The Mask filter; GeometryMask is Canvas only |
setTintFill(color) | setTint(color).setTintMode(Phaser.TintModes.FILL). setTintFill still exists, but only logs an error |
Phaser.Geom.Point | Phaser.Math.Vector2 |
Phaser.Math.PI2 | Phaser.Math.TAU, which is now Math.PI * 2. v3's TAU was PI / 2: that's now Phaser.Math.PI_OVER_2 |
Mesh, Plane | Gone. Mesh2D (4.2) draws a 2D mesh |
Phaser.Structs.Set | Native Set. Phaser.Structs.Map still exists |
The full tables are in v3-to-v4-migration.
2. The default game size is 1024x768
Not 800x600. Set width and height in the config, and position by this.scale.width and this.scale.height, not by fixed numbers like (400, 300).
3. Some features are WebGL only
Phaser.AUTO uses WebGL, and since 4.3 it falls back to Canvas if the WebGL context can't be created. So code for AUTO can run in either renderer.
These need WebGL: filters, lighting, Stencil and StencilReference, CustomContext, the Shader, Gradient, Sky and Noise objects, Mesh2D, SpriteGPULayer, TilemapGPULayer, CaptureFrame and clean alpha. In Canvas most of them draw nothing or do nothing, but a Stencil or CustomContext is a plain Container there, so its children are drawn. Guard them:
if (this.renderer.type === Phaser.WEBGL)
{
sprite.enableFilters();
sprite.filters.internal.addGlow(0xffff00);
}
obj.filters is null until enableFilters() is called, and enableFilters() returns without doing anything in Canvas.
4. Use event constants
Write Phaser.Input.Events.POINTER_DOWN, not 'pointerdown'. A mistyped string never fires, and nothing reports it. The constants are in each system's events folder, such as src/scene/events/, src/input/events/ and src/core/events/, as Phaser.Scenes.Events, Phaser.Input.Events, Phaser.Core.Events and so on.
Per-key events are built from a prefix: Phaser.Input.Keyboard.Events.KEY_DOWN + 'SPACE' gives 'keydown-SPACE'.
5. Clean up listeners on SHUTDOWN
A Scene cleans up its own systems. It doesn't remove listeners you put on things which outlive it: this.registry, this.scale, this.game.events, this.sound, or another Scene's events. Remove them on SHUTDOWN, which runs every time the Scene stops or restarts. DESTROY only runs when the Scene is removed from the game.
create ()
{
this.scale.on(Phaser.Scale.Events.RESIZE, this.onResize, this);
this.events.once(Phaser.Scenes.Events.SHUTDOWN, () =>
{
this.scale.off(Phaser.Scale.Events.RESIZE, this.onResize, this);
});
}
6. A custom Game Object adds itself with scene.add.existing(this)
class Player extends Phaser.GameObjects.Sprite
{
constructor (scene, x, y)
{
super(scene, x, y, 'player');
scene.add.existing(this);
}
}
A Game Object has no add property, so this.add.existing(this) throws.
7. Pixels and rounding
roundPixelsdefaults tofalse(it wastruein v3).pixelArt: truesets it totrue, and turns off antialiasing.vertexRoundModeon each Game Object decides when its vertices are rounded. The default,'safeAuto', rounds only an unscaled, unrotated object, when the Camera hasroundPixels. Objects laid edge to edge, such as background tiles, should all use the same mode, such as'fullAuto', or thin gaps show as the Camera moves.
See scale-and-responsive for pixel art.
8. Tint and lighting changed
- A tint has a mode:
setTint(color)multiplies by default, andsetTintMode(Phaser.TintModes.X)changes it. See game-object-components. - Lights need
this.lights.enable()andobj.setLighting(true), not the v3Light2Dpipeline. See lighting.
Which skill to load
| Task | Skill |
|---|---|
| Game config, renderer, FPS, plugins, boot | game-setup-and-config |
| Screen size, fullscreen, resize, pixel art scaling | scale-and-responsive |
| Scenes, switching, parallel scenes, passing data | scenes |
| Loading files, packs, progress bars, CORS | loading-assets |
| Sprites, images, custom Game Object classes | sprites-and-images |
| Text, web fonts, bitmap fonts | text-and-bitmaptext |
| Graphics, shapes, gradients, health bars | graphics-and-shapes |
| Tint, alpha, blend modes, depth, origin, the component matrix | game-object-components |
| Groups, Containers, Layers, pools | groups-and-containers |
| Sprite animations, atlases, Aseprite | animations |
| Tweens and easing | tweens |
| Timers, delays, Timelines, time scale | time-and-timers |
| Keyboard, mouse, touch, drag, gamepad | input-keyboard-mouse-touch |
| Cameras: follow, zoom, shake, minimap, HUD | cameras |
| Arcade Physics: platformers, bullets, overlap | physics-arcade |
| Matter Physics: rigid bodies, constraints | physics-matter |
| Tiled maps, tile collision, GPU tile layers | tilemaps |
| Particles: bursts, trails, explosions | particles |
| Sound, music, audio sprites, unlocking audio | audio-and-sound |
| Filters: glow, blur, shadow, Camera effects | filters-and-postfx |
| Masks, holes, Stencil, cut-outs | masks-and-stencils |
| Lights, normal maps, PointLight | lighting |
| Shaders, custom filters, render nodes | custom-rendering |
| Drawing to textures, snapshots, trails | render-textures |
| Curves, paths, path followers | curves-and-paths |
| Vectors, geometry, intersections, random | geometry-and-math |
| Actions on many objects, array and object utils | actions-and-utilities |
| Storing state, the registry | data-manager |
| Event emitters, custom events, cleanup | events-system |
| Porting a Phaser 3 game | v3-to-v4-migration |
| What's new in 4.0 to 4.3 | v4-new-features |
Finding more
- Every Game Object is in
src/gameobjects/<name>/. Its factory (this.add.x) is in the*Factory.jsfile beside it. - Every config key, with its default, is in
src/core/typedefs/GameConfig.jsandsrc/core/Config.js. - The JSDoc in
src/is the API reference, andtypes/phaser.d.tsis built from it. docs/holds the guides on rendering, shaders, pixel art and lights.
Security
Reviews (0)
Frequently asked questions about phaser4-core
What does the phaser4-core skill do?
The rules every piece of Phaser 4 code must follow, and a map of which Phaser skill to load for each task. Use at the start of any Phaser 4 work: making a new game, adding a Scene, porting from Phaser 3, or when unsure which skill applies. Corrects the v3 habits that break v4 code: preFX, postFX, pipelines, setPipeline, BitmapMask, setMask, Geom.Point, Math.PI2, Mesh and Plane don't exist; setTintFill only logs an error; Math.TAU is now 2 PI; the default game size is 1024x768; roundPixels defaults to false; WebGL-only features need a Canvas guard. Triggers on: Phaser, Phaser 4, phaser game, new game, game config, scene, which skill, v3 code in a v4 project. It's a reusable SKILL.md instruction set that loads into your AI coding assistant on demand, no prompt engineering, no copy-pasting every session.
How do I install the phaser4-core skill?
Run `npx @skills-hub-ai/cli install phaser-phaser4-core` from your terminal. The CLI writes the SKILL.md to the correct location for your AI tool (e.g. ~/.claude/skills/phaser-phaser4-core/ for Claude Code or ~/.cursor/skills/ for Cursor with --target cursor) and adds it to your project's .skills.json lockfile.
Which AI tools does phaser4-core work with?
phaser4-core runs in Claude Code. It follows the open Agent Skills standard (SKILL.md), so the same skill works in every supported tool without modification.
Is the phaser4-core skill free?
Yes. Every skill on skills-hub.ai is free and open-source. There are no premium tiers, paywalls, or usage limits. You only pay for whatever AI assistant you're already using.
How do I use phaser4-core after installing it?
In Claude Code, type `/phaser-phaser4-core` (or whatever slash command the skill registers) and the AI follows the skill's instructions immediately. You can also reference it by name in natural language, your AI loads the skill into context when relevant.
Can I share the phaser4-core skill with my team?
Yes. Commit your project's .skills.json lockfile and teammates run `npx @skills-hub-ai/cli install` (no args) to install every skill at the exact version you pinned. Organization-scoped installs work via skills-hub.ai organizations.
Badge for your README
Show that this skill is on Skills Hub. The badge links back to this page and shows the live install count.
[](https://skills-hub.ai/skills/phaser-phaser4-core)<a href="https://skills-hub.ai/skills/phaser-phaser4-core"><img src="https://skills-hub.ai/api/badges/skill/phaser-phaser4-core" alt="Install on Skills Hub"></a>More options in the badge docs.