Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

phaser

БесплатноБез исполняемых скриптовНе проверен

Phaser is an open-source HTML5 framework for 2D browser games, with scenes, Arcade and Matter.js physics, sprite animation, tilemaps, tweens, particles and…

TerminalSkillsот TerminalSkills★ 221 звезда на GitHub

Об этом скилле

Phaser

Overview

Phaser is a JavaScript/TypeScript game framework. A Phaser.Game runs a list of scenes (preload, create, update), each with its own physics world, cameras, input, tweens and timers. The current release is Phaser 4 (4.2.1, July 2026; npm install phaser installs it). Most Phaser 3 scene code keeps working, but v4 replaced the WebGL pipeline system, so check the migration notes below before upgrading or when copying older tutorials.

Instructions

1. Create a project

npm create vite@latest star-collector -- --template vanilla-ts
cd star-collector && npm install phaser && npm run dev

Official starters also exist: create-phaser and the phaserjs/template-vite-ts repository. Put images, tilemap JSON and audio in public/assets/ and load them with this.load.setPath("assets").

2. 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; the Canvas renderer is deprecated in v4
  width: 800,
  height: 600,
  pixelArt: true,                         // Nearest-neighbour scaling, no smoothing
  // roundPixels defaults to false in v4; set it only if you see seams in pixel art
  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);

3. Scenes, tilemaps, animation

// 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;
  private cursors!: Phaser.Types.Input.Keyboard.CursorKeys;

  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
    });
    this.anims.create({
      key: "idle",
      frames: [{ key: "hero", frame: 6 }],
    });
    this.cursors = this.input.keyboard!.createCursorKeys();   // create once, not in update()

    // 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.cursors;

    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 { x, y } = coin.body!.position;
    const particles = this.add.particles(x, y, "sparkle", {
      speed: 100,
      lifespan: 300,
      scale: { start: 0.5, end: 0 },
      emitting: false,
    });
    particles.explode(8);
    this.time.delayedCall(400, () => particles.destro
Полный SKILL.md на GitHub

Установить phaser в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

_scores.json

FAQ

Что делает скилл phaser?

Phaser is an open-source HTML5 framework for 2D browser games, with scenes, Arcade and Matter.js physics, sprite animation, tilemaps, tweens, particles and input handling, rendered with WebGL. Use when a user asks to "make a browser game", "build a platformer or arcade game in JavaScript/TypeScript", "set up Phaser with Vite", "add a tilemap, physics or particles", or "upgrade a game from Phaser 3 to Phaser 4".

Как установить скилл phaser?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл phaser запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить phaser с