phaser4-gamedev
安装方式
先用 Prompt 核对来源与依赖。也可下载安装包。
用 AI 助手安装
复制提示词,让助手先核对固定版本和依赖。
查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "phaser4-gamedev":https://skillpi.com/zh/skills/deepskill-0d2aa98873f50493678d5cad35979f7466cc72cf4a8bbefdbc8ea8346399da16。安装前核对上游来源和版本:https://github.com/chongdashu/vibejam-starter-pack。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。
来源与配置
github.com
配置方式待核实
请查看原始来源中的适用工具、依赖和权限要求。
安装实测待补充
使用 Phaser 4 构建 2D 浏览器游戏:优先使用 WebGL 渲染,支持场景、滤镜、光照、着色器、DynamicTexture 与 RenderTexture、瓦片地图、SpriteGPULayer、TilemapGPULayer,以及从 Phaser 3 到 Phaser 4 的迁移工作。
介绍来源: third_party · chongdashu · 0.0.1 参考来源
SkillPi 解读
- 能完成的任务
- 翻译待完成,请参阅来源文档。
- 实测状态
- 未测试
文件浏览
Frontmatter
name: phaser4-gamedev
description: "Build 2D browser games with Phaser 4: WebGL-first rendering, scenes, filters, lighting, shaders, DynamicTexture and RenderTexture, tilemaps, SpriteGPULayer, TilemapGPULayer, and Phaser 3 to 4 migration work."
metadata:
short-description: "Phaser 4 game dev and migration."Phaser 4 Game Development
Build 2D browser games using Phaser 4's WebGL-first renderer, scene model, and updated rendering APIs.
Philosophy: Renderer-Aware, Asset-Exact
Phaser 4 is not Phaser 3 with a few renamed methods. The renderer, filter model, shader assumptions, texture orientation, and batching behavior changed. Good Phaser 4 work starts by choosing the right rendering path and measuring assets before code is written.
Before coding, ask:
- Is this a new Phaser 4 feature or a Phaser 3 migration?
- Does this feature stay on standard game object APIs, or does it depend on filters, shaders, lighting, or custom rendering?
- What is the asset source of truth: exact frame size, spacing, margin, atlas bounds, and texture orientation?
- Is the bottleneck CPU object churn, GPU fill rate, or batch breaking?
- Would
SpriteGPULayer,TilemapGPULayer,RenderTexture, or a plainSpritesolve this more cleanly?
Core principles:
- WebGL-first, not Canvas-first: Phaser 4 is designed around WebGL. Treat Canvas as legacy compatibility, not the default target.
- Measure assets before loader config: Sprite and tile bugs often start as incorrect frame metadata, not rendering bugs.
- Prefer the simplest rendering path: Use standard game objects until scale or effect requirements justify filters, GPU layers, or shader work.
- Treat rendering features as architectural choices: Filters, lighting, shaders, and render textures affect coordinate systems, batching, and debugging.
- Migration is selective redesign: Basic scene code may port cleanly, but masks, FX, custom pipelines, shaders, and texture workflows usually need real updates.
STOP: Before Loading Any Spritesheet or Atlas
Read references/spritesheets-and-textures.md first.
Spritesheet loading is still fragile. A few pixels off in frame size, spacing, or margin can create silent corruption that looks like animation or rendering bugs later.
NEVER guess frame dimensions.
DO NOT assume texture orientation details are irrelevant if compressed textures or custom shaders are involved.
STOP: Before Porting Phaser 3 Code
Read references/migration-hotspots.md first.
Search for the Phaser 3 APIs that changed meaning or disappeared. These are where most migration time goes:
setTintFillBitmapMaskpreFX/postFXPhaser.Geom.PointMath.TAU/Math.PI2setPipeline('Light2D')DynamicTexture/RenderTexture- custom pipelines
- custom shader code
TileSpritecropping
Reference Files
Read these before working on the relevant feature:
| When working on... | Read first |
|---|---|
| Migrating Phaser 3 code | references/migration-hotspots.md |
| Loading spritesheets, atlases, compressed textures, or TileSprite | references/spritesheets-and-textures.md |
| Performance issues, GPU layers, filters, lighting, or batching | references/rendering-and-performance.md |
Architecture Decisions (Make Early)
Rendering Path Choice
| Path | Use when |
|---|---|
| Standard game objects | Most gameplay, UI, and ordinary animation |
SpriteGPULayer |
Very large numbers of mostly simple quads or particle-like members |
TilemapGPULayer |
Very large orthographic tile layers using one tileset |
RenderTexture / DynamicTexture |
You need capture, compositing, stamping, or texture reuse |
| Filters / Shader | The effect is genuinely image-space or shader-driven |
Physics System Choice
| System | Use when |
|---|---|
| Arcade | Platformers, shooters, most 2D action games |
| Matter | Physics puzzles, compound bodies, more realistic collisions |
| None | Menu scenes, card games, visual novels, strategy UIs |
Scene Structure
scenes/
├── BootScene.ts # Asset loading, progress bar, shader/texture setup
├── MenuScene.ts # Title screen and options
├── GameScene.ts # Main gameplay
├── UIScene.ts # HUD overlay (launched in parallel)
└── GameOverScene.ts # End screen and restart flow
Scene Transitions
this.scene.start('GameScene', { level: 1 }); // Stop current, start new
this.scene.launch('UIScene'); // Run in parallel
this.scene.pause('GameScene'); // Pause
this.scene.stop('UIScene'); // Stop
Core Patterns
Game Configuration
Prefer explicit WebGL unless there is a concrete reason not to.
const config: Phaser.Types.Core.GameConfig = {
type: Phaser.WEBGL,
width: 800,
height: 600,
roundPixels: false,
scale: {
mode: Phaser.Scale.FIT,
autoCenter: Phaser.Scale.CENTER_BOTH
},
physics: {
default: 'arcade',
arcade: { gravity: { y: 300 }, debug: false }
},
scene: [BootScene, MenuScene, GameScene]
};
Scene Lifecycle
class GameScene extends Phaser.Scene {
init(data: unknown) {} // Receive data from previous scene
preload() {} // Load assets before create
create() {} // Set up game objects, physics, input
update(time: number, delta: number) {} // Use delta for frame-rate independence
}
Frame-Rate Independent Movement
// Correct: scales with frame rate
this.player.x += this.speed * (delta / 1000);
// Wrong: varies with frame rate
this.player.x += this.speed;
Phaser 4 Migration Replacements
// Phaser 3
sprite.setTintFill(0xff0000);
// Phaser 4
sprite.setTint(0xff0000).setTintMode(Phaser.TintModes.FILL);
// Phaser 3
sprite.setPipeline('Light2D');
// Phaser 4
sprite.setLighting(true);
// Phaser 3
const mask = new Phaser.Display.Masks.BitmapMask(scene, maskObject);
sprite.setMask(mask);
// Phaser 4
sprite.filters.internal.addMask(maskObject);
RenderTexture and DynamicTexture
Phaser 4 buffers drawing commands. If you queue drawing work into a DynamicTexture or RenderTexture, execute it deliberately.
const rt = this.add.renderTexture(0, 0, 256, 256);
rt.draw(sprite, 0, 0);
rt.render();
Use preserve() or render modes only when they solve a concrete problem. Extra indirection complicates debugging quickly.
Pixel Rounding
Do not assume old roundPixels behavior. Phaser 4 defaults it to false, and per-object control is more explicit.
sprite.vertexRoundMode = 'safe';
Use rounding intentionally for pixel art. Leave it off for rotated, scaled, or camera-heavy scenes unless you want the visual tradeoff.
Anti-Patterns to Avoid
| Anti-pattern | Why it hurts | Better |
|---|---|---|
| Treating Phaser 4 as a drop-in Phaser 3 upgrade | You miss renderer, filter, shader, and texture changes | Audit migration hotspots first, then port intentionally |
| Starting new work on Canvas-first assumptions | Many Phaser 4 features are WebGL-centric or unavailable in Canvas | Design for WebGL and treat Canvas as fallback only if required |
| Guessing spritesheet or atlas metadata | Visual corruption appears far away from the actual mistake | Measure frames, spacing, margin, and bounds before loading |
| Using filters or shaders for every visual effect | More complexity, more batch breaks, harder debugging | Use plain sprites, textures, and tint where possible |
| Applying lighting or filters everywhere | Shader changes break batches and can tank performance | Reserve them for objects that benefit visually |
Forgetting render() on DynamicTexture or RenderTexture |
Queued work never lands on the texture | Make render execution explicit in the workflow |
Using SpriteGPULayer for frequently mutated gameplay entities |
Its strength is scale, not arbitrary object behavior | Keep complex interactive entities on normal game objects |
Assuming TilemapGPULayer is a universal tilemap replacement |
It is orthographic-only and more constrained | Use it when the layer size and rendering profile justify it |
Making raw gl calls outside supported integration points |
You can desync Phaser's renderer state | Use Extern or higher-level Phaser APIs |
Common pitfall: "the port compiles, so the migration is done." Rendering, shader, and texture bugs often survive the first compile.
Variation Guidance
Avoid converging on a single Phaser 4 setup. Choose based on context:
- Rendering path: standard objects vs GPU layers vs textures vs shader/filter pipelines
- Physics: Arcade vs Matter vs none
- Content: tilemaps vs pure sprites vs hybrid
- Pixel art handling:
roundPixelsoff, safe per-object rounding, or deliberate full rounding - Assets: spritesheets vs atlases vs single textures
- Scene layout: separate
UIScenevs in-scene HUD
What should vary is the architecture, not the rigor. Measure assets, check batching costs, and adapt the solution to the game's real constraints.
Remember
Phaser 4 gives you a more capable renderer and more explicit rendering tools, but it expects better architectural choices in return.
Before coding: what rendering path are you choosing, what assets define the truth, and what batch-breaking features are actually worth their cost?
Codex can do strong Phaser 4 work when the problem is framed precisely: scene boundaries, asset dimensions, rendering constraints, performance targets, and migration scope. These guidelines illuminate the path; they do not replace engineering judgment.
版本历史
-
v1.2.1
GitHub ↗
原版更新说明
## [1.2.1] - 2026-04-12 ### Added - CHANGELOG.md - Phaser 4 game dev agent skill (`phaser4-gamedev`) — WebGL-first renderer, filters, lighting, shaders, SpriteGPULayer, TilemapGPULayer, and Phaser 3 → 4 migration guidance - "How I'm Vibe Coding A Game For the Vibe Jam" tutorial video
-
v1.1.0
GitHub ↗
原版更新说明
Updated starter pack with .agents layout, improved README/START-HERE guidance, and refreshed release zip.
-
v1.0.0
GitHub ↗
原版更新说明
Free Vibe Jam starter pack — battle-tested ThreeJS and Phaser agent skills, starter projects, and prompts.
当前收录版本
0.0.1
安全与评测信息
质量评测
满分100 · 来自 SkillPi LAB 实验室的评测报告。
亮点
- Comprehensive and practical guidance for a specialized developer audience building 2D browser games with Phaser 4.
- Addresses a clear niche with valuable content on architecture, migration, and best practices.
待提升项
-
Trigger phrases could be more specific for sub-features 原报告严重程度:轻微
The main trigger 'Phaser 4' is clear but broad. Adding specific triggers for sub-features like 'migrate Phaser 3 to 4' or 'use SpriteGPULayer' would improve precision.
改进建议:Consider adding more granular trigger phrases in the description or metadata to cover specific functionalities like migration, GPU layers, or texture handling.
亮点
- Clear and relevant description that accurately reflects the Skill's purpose.
待提升项
-
Reference files missing 原报告严重程度:重大
The main document contains multiple 'STOP' directives and a reference table directing users to read external files (e.g., `references/spritesheets-and-textures.md`, `references/migration-hotspots.md`) before proceeding. These files are not included in the provided content, creating a critical gap for users.
改进建议:Either include the referenced files in the Skill package or integrate their essential content directly into the main document to ensure a complete and self-contained user experience.
亮点
- Well-organized structure with clear sections, code examples, and actionable guidance.
- Effective use of 'STOP' directives to highlight critical pre-requisites.
亮点
- Strong emphasis on best practices, anti-patterns, and architectural decision-making.
- Provides clear warnings about common pitfalls and encourages measuring assets before coding.
取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。
正文静态检测
100 / 100 · skillpi-20261123-no-r3-v1
正文未命中当前规则。
分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。
权限与使用前检查
根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。
未从主文档识别到上述常见操作,不能据此判断无需权限或没有风险。
安全评级与访问范围
safe · 静态证据核验,不代表运行安全保证。
使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。
用户讨论
还没有已核实的点评。