Token导航 LogoToken导航TokenDH.com
研究检索操作浏览器github未标认证来源可访问clear审计通过

writing-phaser-3-games编写 Phaser 3 游戏

Agent Skill

用于辅助文档、README、Markdown、说明文和内容稿件的整理与改写。它适合让 Agent 提炼结构、补齐章节、统一术语、检查链接或把零散材料整理成可读文档。使用时应保留项目已有事实、命令和路径,不要把未确认的信息写成确定结论;涉及对外文案时,还需要控制语气,避免过度营销或夸大能力。

总安装

30,752

周安装

765

GitHub Stars

公开资料未说明

下载量

6,108
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

3

许可证

MIT

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:writing-phaser-3-games(编写 Phaser 3 游戏)
来源仓库:https://github.com/tomcoolpxl/sugar-splat
仓库路径:skills/writing-phaser-3-games
安装命令:
npx skills add https://github.com/tomcoolpxl/sugar-splat --skill 'Writing Phaser 3 Games'
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。不同来源提供的安装方式可能略有差异;本站展示可直接复制的安装命令,安装前请核对来源页面。

skills.shnpx skills
npx skills add https://github.com/tomcoolpxl/sugar-splat --skill 'Writing Phaser 3 Games'

简介

用于编写 Phaser 3 游戏引擎相关的代码和说明。

  • 适合生成游戏逻辑、场景管理和资源加载代码。
  • 可辅助创建 HTML5 网页游戏原型。
  • 需熟悉 Phaser 3 API 和 Web 开发基础。
  • 输出代码应经过测试以确保功能正常。writing-phaser-3-games 属于研究检索类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

Phaser 3 Game Development Skill

Quick Start

Most Common Patterns

Multi-Scene Flow

const config = {
    scene: [ Boot, Preloader, MainMenu, Game, GameOver ]
};
// Boot → Preloader → MainMenu → Game → GameOver

Object Pooling

create() {
    this.projectiles = this.physics.add.group({
        classType: Projectile,
        frameQuantity: 20,
        active: false,
        visible: false
    });
}

fire() {
    const projectile = this.projectiles.getFirstDead(false);
    if (projectile) projectile.fire(x, y);
}

Global Animations

// In Preloader.js create()
this.anims.create({
    key: 'walk',
    frames: this.anims.generateFrameNumbers('player', { start: 0, end: 3 }),
    frameRate: 10,
    repeat: -1
});

JustDown Input

if (Phaser.Input.Keyboard.JustDown(this.spacebar)) {
    this.jump();
}

Navigation Guide

How to Use This Skill

This skill provides access to 18 comprehensive pattern files covering all aspects of Phaser 3 development. Each file contains detailed patterns, code examples, and best practices.

To find specific patterns:

# Read a specific topic
Read knowledgebase/06-input-handling.md

# Search for a pattern across all files
grep -r "object pooling" knowledgebase/

# Find patterns by keyword
grep -i "animation" knowledgebase/*.md
grep -i "collision" knowledgebase/*.md

Quick lookup by number:

  • 01 = Scene Architecture
  • 02 = Asset Management
  • 03 = Physics & Collision
  • 04 = Movement Patterns
  • 05 = Animation System
  • 06 = Input Handling
  • 07 = State Management
  • 08 = Object Pooling & Memory
  • 09 = Grid Systems
  • 10 = Custom Game Objects
  • 11 = UI/HUD Patterns
  • 12 = Tween & Visual Effects
  • 13 = Audio Integration
  • 14 = Game Loop Patterns
  • 15 = Algorithm Implementations
  • 16 = Performance Optimization
  • 17 = Code Organization
  • 18 = Development Philosophy

Table of Contents

1. Scene Architecture

knowledgebase/01-scene-architecture.md

Multi-scene flow, parallel scenes for UI overlays, scene transitions with effects, data passing between scenes.

Key Patterns:

  • Boot → Preloader → MainMenu → Game → GameOver flow
  • Parallel UI scene with scene.launch()
  • Camera fade transitions
  • Scene data passing via init(data)

2. Asset Management

knowledgebase/02-asset-management.md

Two-stage loading, texture atlases, multi-format audio, font synchronization.

Key Patterns:

  • Bootstrap assets in Boot, full assets in Preloader
  • Texture atlas for multiple sprites
  • Multi-format audio for browser compatibility
  • WebFont loading synchronization

3. Physics & Collision

knowledgebase/03-physics-collision.md

Physics configuration, collision vs overlap, dynamic responses, state-gated collision.

Key Patterns:

  • Collider for physical blocking, overlap for triggers
  • Position-based dynamic response (paddle hits)
  • State-gated collision checks
  • Per-track/layer collision isolation

4. Movement Patterns

knowledgebase/04-movement-patterns.md

Velocity-based, time-based discrete, timer-based, pursuit, direction validation, screen wrapping.

Key Patterns:

  • Velocity-based for continuous action games
  • Time-based discrete for grid games
  • Timer-based for turn-based games
  • Direction validation (prevent 180° turns)

5. Animation System

knowledgebase/05-animation-system.md

Global animation creation, reverse animations, animation-driven logic, state-based control.

Key Patterns:

  • Create animations once in Preloader, use everywhere
  • Animation events for gameplay synchronization
  • State-based animation control with caching
  • External animation JSON data

6. Input Handling

knowledgebase/06-input-handling.md

Keyboard, pointer, touch, JustDown pattern, dual input support, input gating, cleanup.

Key Patterns:

  • JustDown for single-press detection
  • Dual keyboard + pointer support
  • Input gating during animations
  • Event-driven pointer movement
  • One-time input with once()

7. State Management

knowledgebase/07-state-management.md

Scene-level state, registry for persistence, localStorage, GameObject data component, state machines.

Key Patterns:

  • Constructor for config, init() for resettable state
  • Registry for cross-scene data
  • GameObject data component for custom properties
  • Boolean flags vs state machines

8. Object Pooling & Memory

knowledgebase/08-object-pooling-memory.md

Group-based pooling, enable/disable pattern, object reuse, dynamic texture cleanup.

Key Patterns:

  • Pre-create with frameQuantity, recycle with getFirstDead()
  • Enable/disable instead of create/destroy
  • Reset pattern for reusable objects
  • Dynamic texture cleanup prevention

9. Grid Systems

knowledgebase/09-grid-systems.md

Dual coordinates, 2D arrays, adjacency helpers, grid alignment, visualization.

Key Patterns:

  • Separate grid coordinates from pixel coordinates
  • 2D array with bounds checking
  • Adjacency helpers (8-direction, 4-direction)
  • Grid-aligned group creation

10. Custom Game Objects

knowledgebase/10-custom-game-objects.md

Extending Sprite/Image, composition pattern, extending groups, self-registration.

Key Patterns:

  • Extend Sprite when physics + animations needed
  • Extend Image for static sprites with physics
  • Composition for non-visual managers
  • Must call super.preUpdate() for animations

11. UI/HUD Patterns

knowledgebase/11-ui-hud-patterns.md

Text styling, positioning, dynamic updates, bitmap fonts, icon counters, layering.

Key Patterns:

  • Text origin for positioning (top-left, center, etc.)
  • Animated counters with tweens
  • Icon-based counters (hearts, lives)
  • Depth/z-ordering for layered UI

12. Tween & Visual Effects

knowledgebase/12-tween-visual-effects.md

Basic tweens, staggered animations, choreographed sequences, camera effects, particles.

Key Patterns:

  • Tween callbacks for sequencing
  • Staggered grid animations
  • Choreographed sequences with accumulating delays
  • Camera shake, flash, fade
  • Particle emitters

13. Audio Integration

knowledgebase/13-audio-integration.md

Sound management, audio lock handling, centralized audio, delayed/sequenced audio.

Key Patterns:

  • Multi-format audio loading
  • Audio lock detection and handling
  • Centralized audio management in UI scene
  • Persistent music across scenes

14. Game Loop Patterns

knowledgebase/14-game-loop-patterns.md

Standard update, minimal event-driven, preUpdate for custom objects, delegation, timers.

Key Patterns:

  • Early exit guards in update()
  • Event-driven for turn-based games
  • Timer-based recurring/one-shot events
  • Update delegation to managers

15. Algorithm Implementations

knowledgebase/15-algorithm-implementations.md

Flood fill, smart random placement, solvable puzzle generation, proximity calculation, following chains, AI.

Key Patterns:

  • Recursive flood fill with 4-direction spread
  • Valid position collection for guaranteed placement
  • Walker algorithm for solvable puzzles
  • Following chain with ShiftPosition

16. Performance Optimization

knowledgebase/16-performance-optimization.md

Object pooling, texture caching, minimize update logic, event-driven, static groups.

Key Patterns:

  • Object pooling eliminates GC pauses
  • Static groups for immovable objects
  • Event-driven over polling in update()
  • Texture atlas for rendering performance

17. Code Organization

knowledgebase/17-code-organization.md

File structure, ES6 modules, constants management, separation of concerns.

Key Patterns:

  • Scenes, gameobjects, managers, utils, constants folders
  • ES6 module imports
  • Constant files for sprite/animation/audio keys
  • Clear initialization order in create()

18. Development Philosophy

knowledgebase/18-development-philosophy.md

Architecture principles, when to use physics, scene decisions, update vs events, progressive difficulty.

Key Patterns:

  • When to use physics vs manual logic
  • Single vs multi vs parallel scenes
  • Update() vs event-driven approaches
  • Progressive difficulty patterns

Core Patterns Reference

Scene Setup

export default class Game extends Phaser.Scene {
    constructor() {
        super('Game');
        // Configuration constants
        this.GRID_SIZE = 32;
    }

    init() {
        // Reset resettable state
        this.score = 0;
        this.gameOver = false;
    }

    create() {
        // Initialize objects
        this.player = new Player(this);
        this.enemies = this.physics.add.group();

        // Setup collisions
        this.physics.add.collider(this.player, this.enemies, this.onHit, null, this);
    }

    update(time, delta) {
        if (this.gameOver) return;
        // Game logic
    }
}

Custom Game Object

export default class Player extends Phaser.Physics.Arcade.Sprite {
    constructor(scene, x, y) {
        super(scene, x, y, 'player');

        // Self-register
        scene.add.existing(this);
        scene.physics.add.existing(this);

        // Configuration
        this.setCollideWorldBounds(true);
        this.isAlive = true;
    }

    preUpdate(time, delta) {
        super.preUpdate(time, delta);  // ESSENTIAL for animations

        if (!this.isAlive) return;
        this.handleMovement();
    }
}

Grid System

// Dual coordinate system
this.gridX = 5;
this.gridY = 3;
this.sprite.x = this.gridX * TILE_SIZE;
this.sprite.y = this.gridY * TILE_SIZE;

// 2D array with bounds checking
getCellXY(x, y) {
    if (x < 0 || x >= this.width || y < 0 || y >= this.height) {
        return null;
    }
    return this.grid[y][x];
}

Collision Handling

// Physical collision
this.physics.add.collider(player, platforms);

// Trigger-based overlap
this.physics.add.overlap(player, coins, this.collectCoin, null, this);

// Collision with state gates
onHit(player, enemy) {
    if (!player.isAlive) return;
    if (player.invincible) return;
    if (enemy.alpha < 1) return;

    this.handleDamage(player, enemy);
}

Input Patterns

create() {
    // Cursor keys
    this.cursors = this.input.keyboard.createCursorKeys();

    // Specific key
    this.spacebar = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.SPACE);

    // Pointer/touch
    this.input.on('pointerdown', this.handleClick, this);
}

update() {
    // Continuous input
    if (this.cursors.left.isDown) {
        this.player.setVelocityX(-160);
    }

    // Single-press input
    if (Phaser.Input.Keyboard.JustDown(this.spacebar)) {
        this.jump();
    }
}

Animation Setup

// In Preloader create() - global animations
this.anims.create({
    key: 'player-walk',
    frames: this.anims.generateFrameNumbers('player', { start: 0, end: 3 }),
    frameRate: 10,
    repeat: -1
});

// In Game create() - use animations
this.player.play('player-walk');

// Animation events
this.player.on('animationcomplete-attack', this.spawnProjectile, this);

State Management

// Scene-level state
init() {
    this.score = 0;
    this.lives = 3;
    this.gameOver = false;
}

// Registry for cross-scene data
this.registry.set('highscore', this.score);
const highscore = this.registry.get('highscore');

// GameObject data
sprite.setData({ gridX: 5, gridY: 3, type: 'enemy' });
const gridX = sprite.data.values.gridX;

Common Pitfalls

Critical mistakes to avoid:

  1. Forgetting super.preUpdate(time, delta) in custom sprites

- Animations won't work without this - Always call first thing in preUpdate()

  1. Not calling refreshBody() after scaling static groups this.platforms.create(x, y, 'platform').setScale(2).refreshBody(); // REQUIRED
  2. Creating objects in update() instead of pooling

- Causes GC pauses and poor performance - Pre-create pools, recycle with enable/disable

  1. Missing bounds checks on grid access if (x < 0 || x >= width || y < 0 || y >= height) return null;
  2. Not cleaning up listeners/timers shutdown() {this.input.off('pointerdown', this.handleClick); if (this.timer) this.timer.remove();}
  3. Using wrong collision method

- Use collider for physical blocking - Use overlap for triggers/pickups

  1. Polling in update() when events would work

- Use physics overlap instead of distance checks - Use pointer events instead of checking every frame

  1. Hard-coding values instead of constants // Bad: magic numbers sprite.x = 400; // Good: named constants const GRID_SIZE = 32; sprite.x = gridX * GRID_SIZE;
  2. Not resetting state in init()

- Scene restart won't work properly - Put all resettable state in init(), not constructor

  1. Ignoring context binding in callbacks // Use arrow functions or bind this.time.delayedCall(1000, () => this.start(), [], this);

Performance Tips

  • Object pools for frequently created/destroyed objects
  • Texture atlases combine sprites into single image
  • Static groups for immovable platforms/walls
  • Event-driven over polling in update()
  • Minimal update logic - only what's necessary each frame
  • Cache lookups - don't search arrays every frame
  • Set depth once - don't sort every frame

When to Read Detailed Files

Starting a new game? → Read 01-scene-architecture.md

Performance issues? → Read 16-performance-optimization.md

Grid-based game? → Read 09-grid-systems.md

Complex animations? → Read 05-animation-system.md and 12-tween-visual-effects.md

Input problems? → Read 06-input-handling.md

Memory leaks? → Read 08-object-pooling-memory.md

Implementing algorithms? → Read 15-algorithm-implementations.md

Architecture decisions? → Read 18-development-philosophy.md

Quick Reference Cheat Sheet

Scene Flow

Boot → Preloader → MainMenu → Game → GameOver
this.scene.start('NextScene', { score: this.score });
this.scene.launch('GameUI');  // Parallel scene

Physics

this.physics.add.collider(a, b);        // Physical blocking
this.physics.add.overlap(a, b, callback); // Trigger only
sprite.setCollideWorldBounds(true);
sprite.setImmovable(true);

Groups & Pooling

this.items = this.physics.add.group({ frameQuantity: 20 });
const item = this.items.getFirstDead(false);
item.enableBody(true, x, y, true, true);
item.disableBody(true, true);

Input

this.cursors = this.input.keyboard.createCursorKeys();
Phaser.Input.Keyboard.JustDown(key)
this.input.on('pointerdown', callback, this);

Tweens

this.tweens.add({
    targets: sprite,
    x: 400,
    duration: 1000,
    ease: 'Power2',
    onComplete: () => {}
});

Camera

this.cameras.main.shake(duration, intensity);
this.cameras.main.fadeOut(duration);
this.cameras.main.flash(duration, r, g, b);

This skill provides comprehensive Phaser 3 patterns. Read the detailed knowledgebase files for in-depth examples and advanced techniques.

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

04

需要参考平台分布和安装热度时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

补充不同宿主或平台的使用分布数据

能力 5

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Claude Code

28.65%
按下载量换算1,750

Antigravity

23.06%
按下载量换算1,409

Gemini CLI

17.26%
按下载量换算1,054

Codex

13.25%
按下载量换算809

OpenCode

8.58%
按下载量换算524

Cursor

3.49%
按下载量换算213

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

操作浏览器

该 Skill 可能涉及浏览器控制能力,使用时可能读取或操作网页内容,需要在受控环境中确认权限边界。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源字段存在多来源差异,先按来源优先级自动处理,无法消解时进入异常复核队列。

来源信息

继续浏览同类 Skills