Skip to main content
BuildOfficialCertifiedReviewed Dec 4, 2026

Phaser4 Core

v1.0.0New

Unsigned, install at your own risk

Unverified

This 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-core

What 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.

Or get the file:
Browse all CLI commands →
Manual setup by platform

Claude Code

~/.claude/skills/phaser-phaser4-core/SKILL.md

Setup guide →
0Save

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 the Phaser global.

The rules

1. These v3 APIs don't exist in v4

Don't write them, and replace them when porting:

v3v4
preFX, postFX, Phaser.FXFilters: obj.enableFilters(), then obj.filters.internal / obj.filters.external
setPipeline, pipelines, PostFXPipelineRender nodes; setLighting(true) for lights
BitmapMask, setMask, createBitmapMaskThe Mask filter; GeometryMask is Canvas only
setTintFill(color)setTint(color).setTintMode(Phaser.TintModes.FILL). setTintFill still exists, but only logs an error
Phaser.Geom.PointPhaser.Math.Vector2
Phaser.Math.PI2Phaser.Math.TAU, which is now Math.PI * 2. v3's TAU was PI / 2: that's now Phaser.Math.PI_OVER_2
Mesh, PlaneGone. Mesh2D (4.2) draws a 2D mesh
Phaser.Structs.SetNative 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

  • roundPixels defaults to false (it was true in v3). pixelArt: true sets it to true, and turns off antialiasing.
  • vertexRoundMode on each Game Object decides when its vertices are rounded. The default, 'safeAuto', rounds only an unscaled, unrotated object, when the Camera has roundPixels. 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, and setTintMode(Phaser.TintModes.X) changes it. See game-object-components.
  • Lights need this.lights.enable() and obj.setLighting(true), not the v3 Light2D pipeline. See lighting.

Which skill to load

TaskSkill
Game config, renderer, FPS, plugins, bootgame-setup-and-config
Screen size, fullscreen, resize, pixel art scalingscale-and-responsive
Scenes, switching, parallel scenes, passing datascenes
Loading files, packs, progress bars, CORSloading-assets
Sprites, images, custom Game Object classessprites-and-images
Text, web fonts, bitmap fontstext-and-bitmaptext
Graphics, shapes, gradients, health barsgraphics-and-shapes
Tint, alpha, blend modes, depth, origin, the component matrixgame-object-components
Groups, Containers, Layers, poolsgroups-and-containers
Sprite animations, atlases, Asepriteanimations
Tweens and easingtweens
Timers, delays, Timelines, time scaletime-and-timers
Keyboard, mouse, touch, drag, gamepadinput-keyboard-mouse-touch
Cameras: follow, zoom, shake, minimap, HUDcameras
Arcade Physics: platformers, bullets, overlapphysics-arcade
Matter Physics: rigid bodies, constraintsphysics-matter
Tiled maps, tile collision, GPU tile layerstilemaps
Particles: bursts, trails, explosionsparticles
Sound, music, audio sprites, unlocking audioaudio-and-sound
Filters: glow, blur, shadow, Camera effectsfilters-and-postfx
Masks, holes, Stencil, cut-outsmasks-and-stencils
Lights, normal maps, PointLightlighting
Shaders, custom filters, render nodescustom-rendering
Drawing to textures, snapshots, trailsrender-textures
Curves, paths, path followerscurves-and-paths
Vectors, geometry, intersections, randomgeometry-and-math
Actions on many objects, array and object utilsactions-and-utilities
Storing state, the registrydata-manager
Event emitters, custom events, cleanupevents-system
Porting a Phaser 3 gamev3-to-v4-migration
What's new in 4.0 to 4.3v4-new-features

Finding more

  • Every Game Object is in src/gameobjects/<name>/. Its factory (this.add.x) is in the *Factory.js file beside it.
  • Every config key, with its default, is in src/core/typedefs/GameConfig.js and src/core/Config.js.
  • The JSDoc in src/ is the API reference, and types/phaser.d.ts is built from it.
  • docs/ holds the guides on rendering, shaders, pixel art and lights.
This skill doesn’t include stateful context yet, instructions only. Learn about stateful skills.

Security

Loading security scan...

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.

Install on Skills Hub badge preview
Markdown
[![Install on Skills Hub](https://skills-hub.ai/api/badges/skill/phaser-phaser4-core)](https://skills-hub.ai/skills/phaser-phaser4-core)
HTML
<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.