phaser

Phaser 专家辅助,用于开发基于 Phaser 的 2D 游戏。覆盖内容包括:场景系统、物理引擎(Arcade 与 Matter.js)、精灵动画、瓦片地图、补间动画、粒子效果与输入处理,适用于制作街机、益智、RPG、平台跳跃与类 Rogue 游戏,并支持 TypeScript 与 Vite 开发工作流。

仓库最近推送
GitHub Stars
218
Forks
37
Issues / PRs
1

安装方式

先用 Prompt 核对来源与依赖。也可下载安装包。

用 AI 助手安装

复制提示词,让助手先核对固定版本和依赖。

查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "phaser":https://skillpi.com/zh/skills/deepskill-a718a33818080585e2d40da8ddb218865d4d056d936404a41ce496d0272a740f。安装前核对上游来源和版本:https://github.com/TerminalSkills/skills。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。

来源与配置

github.com

配置方式待核实

请查看原始来源中的适用工具、依赖和权限要求。

安装实测待补充

Phaser 专家辅助,用于开发基于 Phaser 的 2D 游戏。覆盖内容包括:场景系统、物理引擎(Arcade 与 Matter.js)、精灵动画、瓦片地图、补间动画、粒子效果与输入处理,适用于制作街机、益智、RPG、平台跳跃与类 Rogue 游戏,并支持 TypeScript 与 Vite 开发工作流。

0 下载

介绍来源: third_party · TerminalSkills · 1.0.0 参考来源

SkillPi 解读

实测状态
未测试

文件浏览

在原站浏览文件 ↗

原始 SKILL.md

打开原文 ↗
Frontmatter
name: phaser
description: >-
  You are an expert in Phaser, the fast and feature-rich HTML5 game framework
  for making 2D games that run in web browsers and mobile devices. You help
  developers build arcade games, puzzle games, RPGs, platformers, and
  roguelikes using Phaser's scene system, physics engines (Arcade and
  Matter.js), sprite animations, tilemaps, tweens, particle effects, and input
  handling — with TypeScript support and Vite for modern development workflow.
license: Apache-2.0
compatibility: ''
metadata:
  author: terminal-skills
  version: 1.0.0
  category: Game Development
  tags:
    - game-engine
    - html5
    - browser-game
    - 2d
    - arcade-physics
    - webgl
    - canvas

Phaser — HTML5 Game Framework for Browser Games

You are an expert in Phaser, the fast and feature-rich HTML5 game framework for making 2D games that run in web browsers and mobile devices. You help developers build arcade games, puzzle games, RPGs, platformers, and roguelikes using Phaser's scene system, physics engines (Arcade and Matter.js), sprite animations, tilemaps, tweens, particle effects, and input handling — with TypeScript support and Vite for modern development workflow.

Core Capabilities

Game Configuration

// src/main.ts — Phaser game entry point
import Phaser from "phaser";
import { PreloadScene } from "./scenes/PreloadScene";
import { GameScene } from "./scenes/GameScene";
import { HUDScene } from "./scenes/HUDScene";

const config: Phaser.Types.Core.GameConfig = {
  type: Phaser.AUTO,                      // WebGL → Canvas fallback
  width: 800,
  height: 600,
  pixelArt: true,                         // No anti-aliasing on sprites
  roundPixels: true,                      // Snap to pixel grid
  scale: {
    mode: Phaser.Scale.FIT,               // Fit viewport, keep aspect ratio
    autoCenter: Phaser.Scale.CENTER_BOTH,
  },
  physics: {
    default: "arcade",                    // Fast AABB physics
    arcade: {
      gravity: { x: 0, y: 300 },         // Platformer gravity
      debug: false,
    },
  },
  scene: [PreloadScene, GameScene, HUDScene],
};

new Phaser.Game(config);

Scene System

// src/scenes/GameScene.ts — Main game loop
export class GameScene extends Phaser.Scene {
  private player!: Phaser.Physics.Arcade.Sprite;
  private platforms!: Phaser.Physics.Arcade.StaticGroup;
  private coins!: Phaser.Physics.Arcade.Group;
  private score: number = 0;

  constructor() {
    super("GameScene");
  }

  create() {
    // Tilemap from Tiled editor
    const map = this.make.tilemap({ key: "level-1" });
    const tileset = map.addTilesetImage("terrain", "terrain-tiles")!;
    const ground = map.createLayer("Ground", tileset)!;
    ground.setCollisionByProperty({ collides: true });

    // Player with animations
    this.player = this.physics.add.sprite(100, 200, "hero");
    this.player.setCollideWorldBounds(true);
    this.player.setBounce(0.1);

    this.anims.create({
      key: "run",
      frames: this.anims.generateFrameNumbers("hero", { start: 0, end: 5 }),
      frameRate: 10,
      repeat: -1,                         // Loop forever
    });

    // Collisions
    this.physics.add.collider(this.player, ground);

    // Coins from object layer in Tiled
    const coinObjects = map.getObjectLayer("Coins")!.objects;
    this.coins = this.physics.add.group();
    coinObjects.forEach((obj) => {
      const coin = this.coins.create(obj.x!, obj.y!, "coin");
      coin.setScale(0.5);
      coin.body.setAllowGravity(false);
    });

    this.physics.add.overlap(this.player, this.coins, this.collectCoin, undefined, this);

    // Camera
    this.cameras.main.startFollow(this.player, true, 0.08, 0.08);
    this.cameras.main.setBounds(0, 0, map.widthInPixels, map.heightInPixels);

    // Launch HUD as parallel scene
    this.scene.launch("HUDScene");
  }

  update() {
    const cursors = this.input.keyboard!.createCursorKeys();

    if (cursors.left.isDown) {
      this.player.setVelocityX(-160);
      this.player.anims.play("run", true);
      this.player.setFlipX(true);
    } else if (cursors.right.isDown) {
      this.player.setVelocityX(160);
      this.player.anims.play("run", true);
      this.player.setFlipX(false);
    } else {
      this.player.setVelocityX(0);
      this.player.anims.play("idle", true);
    }

    // Jump (only when touching ground)
    if (cursors.up.isDown && this.player.body!.blocked.down) {
      this.player.setVelocityY(-330);
    }
  }

  private collectCoin(
    _player: Phaser.GameObjects.GameObject,
    coin: Phaser.GameObjects.GameObject,
  ) {
    (coin as Phaser.Physics.Arcade.Sprite).disableBody(true, true);
    this.score += 10;
    this.events.emit("score-changed", this.score);

    // Particle burst effect
    const particles = this.add.particles(coin.body!.position.x, coin.body!.position.y, "sparkle", {
      speed: 100,
      lifespan: 300,
      quantity: 8,
      scale: { start: 0.5, end: 0 },
      emitting: false,
    });
    particles.explode();
  }
}

Physics, Tweens, and Effects

// Arcade physics — fast, axis-aligned
this.physics.add.collider(player, enemies, onHit);
this.physics.add.overlap(bullet, enemies, onBulletHit);
player.setVelocity(200, -300);
player.setBounce(0.2);
player.setDrag(100);

// Matter.js physics — complex shapes, joints, sensors
const ball = this.matter.add.circle(400, 200, 20, { restitution: 0.8 });
const constraint = this.matter.add.constraint(anchor, ball, 100, 0.1);

// Tweens — smooth animations
this.tweens.add({
  targets: sprite,
  y: sprite.y - 50,
  alpha: 0,
  duration: 500,
  ease: "Power2",
  onComplete: () => sprite.destroy(),
});

// Screen shake
this.cameras.main.shake(200, 0.01);

// Time events
this.time.addEvent({
  delay: 2000,
  callback: spawnEnemy,
  loop: true,
});

Installation

# New project with Vite
npm create vite@latest my-game -- --template vanilla-ts
cd my-game
npm install phaser
npm run dev

Best Practices

  1. Scene system — Use separate scenes for menu, game, HUD, pause, game-over; HUD as parallel scene overlay
  2. Arcade physics for simple games — AABB collision is fast and sufficient for most 2D games; Matter.js only when you need complex shapes
  3. Tilemap integration — Design levels in Tiled, export as JSON, load with this.make.tilemap; use object layers for spawn points
  4. Object pooling — Use this.physics.add.group({ maxSize: 50 }) for bullets, particles, enemies; recycle instead of create/destroy
  5. Pixel art — Set pixelArt: true and roundPixels: true in config; prevents blurry scaling on retina displays
  6. Mobile input — Add virtual joystick for touch; Phaser has built-in pointer events for multi-touch
  7. Texture atlases — Pack sprites into atlases (TexturePacker); reduces draw calls from 200+ to 5-10
  8. Camera — Use startFollow with lerp values (0.05-0.1) for smooth camera; set bounds to tilemap size

当前收录版本

1.0.0

核对来源版本 ↗

质量评测

满分100 · 来自 SkillPi LAB 实验室的评测报告。

场景价值85/100

亮点

  • 提供完整的 Phaser 游戏开发能力,涵盖场景系统、物理引擎、动画等核心功能
  • 支持 TypeScript 和 Vite 现代开发工作流,具有实际工程价值
  • 适用于多种游戏类型:街机、益智、RPG、平台跳跃等
触发精准90/100

亮点

  • 触发词精准覆盖 Phaser 相关技术栈
  • 边界清晰,不易与其他游戏开发 Skill 重叠
  • description 完整描述了专家角色和能力范围
结构规范90/100

亮点

  • 结构清晰,包含配置、场景、物理等完整模块
  • 提供端到端代码示例,可直接参考使用
  • frontmatter 完整,文档组织规范
执行可靠85/100

亮点

  • 代码示例完整,参数使用正确
  • 覆盖主要异常情况和最佳实践
  • 提供了可直接执行的 Phaser 配置和场景代码
证据可验 (前四项均值)88/100

取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。

正文静态检测

100 / 100 · skillpi-20261123-no-r3-v1

正文未命中当前规则。

分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。

权限与使用前检查

根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。

  • 安装或获取外部依赖

    使用官方来源并锁定版本,在隔离环境检查安装脚本。当前文档检查不覆盖后续下载的代码。

    主文档提及 · 第 203 行

本站展示提示不会授予权限。涉及文件改动、密钥、外部发送或费用时,仍由你使用的工具按需确认。

安全评级与访问范围

safe · 静态证据核验,不代表运行安全保证。

使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。