Phaser Migrate logo

Phaser Migrate

Organization
Yakoub-ai
phaser-migrate

This skill should be used when the user asks to "migrate from Phaser 3", "upgrade to Phaser 4", "convert my v3 game", "Phaser 3 to 4 migration", "update Phaser version", "my Phaser 3 game broke after upgrading", "behavior changed after upgrading Phaser 4", "upgrade Phaser 4.0 to 4.2", or has code that uses deprecated or removed Phaser 3 APIs or behavior that silently drifted between Phaser 4 RC releases.

Overview

PublisherYakoub-ai
Repositoryphaser4-gamedev
Skill namephaser-migrate
Stars
29
Forks
3
Bundled files
3
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 3 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by Yakoub-ai on GitHub. Read the source before you install it.

Installation

Install the Phaser Migrate AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/Yakoub-ai/phaser4-gamedev/tree/main/skills/phaser-migrate
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/Yakoub-ai/phaser4-gamedev.git /tmp/phaser4-gamedev
mkdir -p .claude/skills
cp -r /tmp/phaser4-gamedev/skills/phaser-migrate .claude/skills/phaser-migrate
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Phaser Migrate in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Phaser Migrate on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Phaser Migrate is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Phaser 3 → Phaser 4 Migration

Migrating from Phaser 3 to Phaser 4 is mostly straightforward. The core public API is preserved. This skill covers every breaking change and how to fix it — AND also covers moving between Phaser 4 point releases (4.0 → 4.1 → 4.2), plus the runtime behaviour that compiles cleanly and still surprises you.

Step 1 — Update the Package

bash
npm uninstall phaser
npm install phaser

Verify installed version:

bash
node -e "const p = require('phaser'); console.log(p.VERSION)"

Should print 4.2.1 (or later RC).

Step 2 — Scan for Breaking Changes

Run these grep searches to find every issue in your src/ directory:

bash
# 1. Point → Vector2
grep -rn "Geom\.Point\|new Phaser\.Geom\.Point\|Geom\.Point\." src/

# 2. Math.PI2 → Math.TAU
grep -rn "Math\.PI2\b" src/

# 3. Phaser.Structs
grep -rn "Phaser\.Structs\." src/

# 4. DynamicTexture / RenderTexture (check for missing .render())
grep -rn "DynamicTexture\|RenderTexture\|addDynamicTexture\|addRenderTexture" src/

# 5. Removed plugins
grep -rn "Camera3D\|Layer3D\|FacebookInstant\|SpinePlugin\|SpineFile" src/

# 6. TileSprite crop (setCrop on TileSprite — no longer supported)
grep -rn "tileSprite.*setCrop\|setCrop.*tileSprite" src/

# 7. Create.GenerateTexture (removed)
grep -rn "Create\.GenerateTexture\|Phaser\.Create\." src/

# 8. Spine (use official Esoteric plugin instead)
grep -rn "spine\|Spine" src/ -i

# 9. phaser-ie9 entry point
grep -rn "phaser-ie9" . 

# 10. WebGL geometry masks (stencil-based masks changed in Phaser 4 — use scissor/viewport instead)
grep -rn "createGeometryMask\|createBitmapMask\|BitmapMask\|setMask\b\|clearMask\|setScissor" src/ 

Step 3 — Apply Fixes

Fix 1: Geom.Point → Vector2

Phaser.Geom.Point is completely removed. Use Phaser.Math.Vector2.

typescript
// BEFORE (Phaser 3)
const point = new Phaser.Geom.Point(x, y);
point.x = 100;
const distance = Phaser.Geom.Point.GetMagnitude(point);
const clone = Phaser.Geom.Point.Clone(point);
Phaser.Geom.Point.SetMagnitude(point, 50);

// AFTER (Phaser 4)
const point = new Phaser.Math.Vector2(x, y);
point.x = 100;
const distance = point.length();
const clone = point.clone();
point.setLength(50);

Full Point → Vector2 method mapping:

Phaser 3 (static)Phaser 4 (instance)
Point.GetMagnitude(pt)pt.length()
Point.Clone(pt)pt.clone()
Point.SetMagnitude(pt, n)pt.setLength(n)
Point.Ceil(pt)pt.ceil()
Point.Floor(pt)pt.floor()
Point.Invert(pt)pt.invert()
Point.Negative(pt)pt.negate()
Point.Project(pt, target, out)pt.project(target)
Point.GetCentroid(points)Phaser.Math.GetCentroid(points)
Point.GetRectangleFromPoints(pts)Phaser.Math.GetVec2Bounds(pts)

All Geometry classes (Circle, Ellipse, Line, Rectangle, Triangle, Polygon) now return Vector2 instead of Point for point-related results.

Fix 2: Math.PI2 → Math.TAU

typescript
// BEFORE (Phaser 3) — NOTE: Math.PI2 was INCORRECTLY π in v3
const fullRotation = Math.PI2;  // was wrong!

// AFTER (Phaser 4)
const fullRotation = Math.TAU;       // Correct π×2
const halfRotation = Math.PI_OVER_2; // π/2 (new constant)

Fix 3: Phaser.Structs → Native JS

typescript
// BEFORE (Phaser 3)
const myMap = new Phaser.Structs.Map([]);
myMap.set('key', value);
myMap.get('key');
myMap.delete('key');
myMap.getArray();

const mySet = new Phaser.Structs.Set();
mySet.set(value);
mySet.delete(value);
mySet.contains(value);

// AFTER (Phaser 4)
const myMap = new Map<string, any>();
myMap.set('key', value);
myMap.get('key');
myMap.delete('key');
[...myMap.values()];

const mySet = new Set<any>();
mySet.add(value);
mySet.delete(value);
mySet.has(value);

Fix 4: DynamicTexture / RenderTexture — Add render()

typescript
// BEFORE (Phaser 3) — drawing happened immediately
const dynTex = this.textures.addDynamicTexture('key', 200, 200);
dynTex.draw('sprite', 0, 0);
// visible immediately

// AFTER (Phaser 4) — must call render() to commit drawing
const dynTex = this.textures.addDynamicTexture('key', 200, 200);
dynTex.draw('sprite', 0, 0);
dynTex.render();   // ← REQUIRED in v4

Fix 5: Removed Plugins

Camera3D — no replacement. Phaser 4 is 2D only. If 3D is needed, use Three.js alongside Phaser.

Layer3D — no replacement. Removed with Camera3D.

Facebook Instant Games — removed. Facebook no longer supports this platform.

Spine Plugin (official v3/v4 Spine support) — use the official Esoteric Software Phaser plugin instead. The Phaser bundled Spine plugin is no longer maintained.

Fix 6: TileSprite Cropping

TileSprite no longer supports texture cropping in Phaser 4.

typescript
// BEFORE (Phaser 3)
const ts = this.add.tileSprite(x, y, w, h, 'texture');
ts.setCrop(0, 0, 100, 100);  // no longer works in v4

// AFTER (Phaser 4) — use RenderTexture instead if cropping is needed
const rt = this.add.renderTexture(x, y, 100, 100);
rt.draw('texture', 0, 0);
rt.render();

Fix 7: Create.GenerateTexture Removed

Phaser.Create.GenerateTexture and all Create Palettes are removed.

typescript
// BEFORE (Phaser 3)
const texture = Phaser.Create.GenerateTexture({ data: palettes, pixelWidth: 2 });

// AFTER (Phaser 4) — use a pre-made image asset, or draw with Graphics
const gfx = this.add.graphics();
gfx.fillStyle(0xff0000);
gfx.fillRect(0, 0, 16, 16);
gfx.generateTexture('red-square', 16, 16);
gfx.destroy();

Fix 8: Removed IE9 Entry Point

typescript
// BEFORE — some projects imported the IE9-compatible build
import Phaser from 'phaser/src/phaser-ie9.js';

// AFTER — just use the standard import
import Phaser from 'phaser';

Fix 9: Masks → Camera Viewport or the Mask Filter

Phaser 4 removed the v3 masking classes. BitmapMask is gone entirely, and neither createGeometryMask() nor createBitmapMask() exists on Game Objects. GeometryMask survives as a class but only the (deprecated) Canvas renderer consumes it — under Beam it does nothing.

typescript
// BEFORE (Phaser 3) — geometry mask via stencil buffer
const shape = this.add.graphics().fillRect(x, y, w, h);
const mask = shape.createGeometryMask();   // removed in v4
targetSprite.setMask(mask);

// AFTER (Phaser 4), rectangular clip — give the content its own camera:
const clipCam = this.cameras.add(x, y, w, h);
clipCam.ignore(this.children.list.filter(c => c !== targetSprite));
this.cameras.main.ignore(targetSprite);

// AFTER (Phaser 4), arbitrary shape — the Mask filter:
targetSprite.enableFilters();                  // filters is null until you call this
targetSprite.filters!.internal.addMask(shape); // texture key or GameObject
targetSprite.filters!.internal.addMask(shape, true);  // inverted

There is no camera.setScissor() in Phaser 4 — that method does not exist on Phaser.Cameras.Scene2D.Camera. Use setViewport().

Phaser.Actions.AddMaskShape() is a convenience that creates a Shape and wires it up as a mask in one call — it is the replacement for the v3 Circle FX.

Step 4 — Update TypeScript Config

If using TypeScript, ensure tsconfig.json is correct for v4:

json
{
  "compilerOptions": {
    "target": "ES2022",
    "lib": ["ES2022", "DOM", "DOM.Iterable"],
    "module": "ESNext",
    "moduleResolution": "bundler",
    "strict": true,
    "skipLibCheck": true,
    "noEmit": true
  },
  "include": ["src"]
}

Phaser 4 publishes its types through the exports map in its own package.json, so a modern resolver picks them up from a plain import Phaser from 'phaser'; with no extra config.

Delete typeRoots: ["./node_modules/phaser/types"] and types: ["Phaser"] if your v3 tsconfig has them. Against Phaser 4 that pair fails with TS2688: Cannot find type definition file for 'Phaser' — v4 ships one types/phaser.d.ts file, which is not a valid type-root package.

Step 5 — Verify and Test

bash
# Type check — must pass with 0 errors
npx tsc --noEmit

# Start dev server and check browser console
npm run dev

Check in browser:

  1. No console errors on startup
  2. All scenes load correctly
  3. Physics behaves the same as v3
  4. Animations play correctly

Quick Migration Checklist

  • npm install phaser run
  • tsconfig.json v3-era typeRoots + types: ["Phaser"] removed; moduleResolution is bundler/node16
  • All Phaser.Geom.Point replaced with Phaser.Math.Vector2
  • All Math.PI2 replaced with Math.TAU
  • All Phaser.Structs.Map/Set replaced with native Map/Set
  • All DynamicTexture/RenderTexture have render() calls after drawing
  • Removed plugin references deleted (Camera3D, Layer3D, Facebook, old Spine)
  • TileSprite.setCrop() calls replaced or removed
  • Phaser.Create.GenerateTexture replaced with Graphics/textures
  • phaser-ie9 imports replaced with phaser
  • WebGL masks (createGeometryMask / createBitmapMask / BitmapMask) replaced with a camera viewport or filters.internal.addMask(); no camera.setScissor() calls
  • npx tsc --noEmit passes
  • node skills/phaser-playtest/scripts/playtest.mjs --project . passes — a green tsc says nothing about whether the migrated game renders

Additional Resources

Reference Files

  • references/v3-to-v4-changes.md — Complete changelog of all Phaser v3→v4 breaking changes, including renderer internals, deprecated APIs, and behavior differences
  • references/runtime-gotchas.md — Behaviour that compiles cleanly and still surprises you: masking, animation state switches, camera follow, tilemap collision, onFloor() timing, cross-scene wiring, scale manager. Read when the compiler is happy but the game is not.
  • references/v4-release-notes.md — What shipped in 4.0.0, 4.1.0, 4.2.0 and 4.2.1, and what to change when moving between them. Read when upgrading Phaser 4 point releases, or to find out whether a bug you are chasing is already fixed upstream.

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Phaser Migrate AI skill do?

This skill should be used when the user asks to "migrate from Phaser 3", "upgrade to Phaser 4", "convert my v3 game", "Phaser 3 to 4 migration", "update Phaser version", "my Phaser 3 game broke after upgrading", "behavior changed after upgrading Phaser 4", "upgrade Phaser 4.0 to 4.2", or has code that uses deprecated or removed Phaser 3 APIs or behavior that silently drifted between Phaser 4 RC releases.

Why use Phaser Migrate on TypingMind?

Because you install it once and use it with any model. Phaser Migrate is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Phaser Migrate in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/Yakoub-ai/phaser4-gamedev/tree/main/skills/phaser-migrate. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Phaser Migrate?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Phaser Migrate?

As many as you like. As long as a model supports skills, you can use Phaser Migrate with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Phaser Migrate AI skill free?

It is published on GitHub by Yakoub-ai. Check the repository for licensing terms. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇