Phaser Buildのロゴ

Phaser Build

組織
Yakoub-ai
phaser-build

This skill should be used when the user asks to "build my game", "run my Phaser game", "start dev server", "deploy my game", "fix build errors", "configure Vite for Phaser", "game won't build", "TypeScript errors in Phaser", "publish to itch.io", or needs to compile, run, troubleshoot, or deploy a Phaser 4 project.

概要

公開者Yakoub-ai
リポジトリphaser4-gamedev
スキル名phaser-build
スター
29
フォーク
3
同梱ファイル
2
リンク
  • Markdown形式の指示

    モデルが必要に応じて読み込むSKILL.mdファイルです。関連するリクエストがあったときだけトークンを消費します。

  • どのLLMでも利用可能

    AIスキルはプロバイダー固有のコードではなく、通常のMarkdownなので、GPT、Claude、Gemini、Grok、ローカルモデルで利用できます。

  • 2個の同梱ファイル

    モデルが作業中に読み取れるスクリプト、テンプレート、参考資料です。ファイルは読み取り専用で、実行されることはありません。

  • オープンソース

    Yakoub-aiがGitHubで公開しています。インストールする前にソースを確認してください。

インストール

AIスキル「Phaser Build」をTypingMindにインストールすれば、どのLLMでも利用できます。SKILL.mdを読み取れる別のAIエージェントに追加することもできます。

1

TypingMindにインストール

TypingMindはGitHubフォルダから直接スキルをインストールします。SKILL.mdを読み取り、リソースファイルをまとめてローカルに保存します。

  1. アプリを開き、「プラグイン」→「スキル」に移動します。
  2. 「GitHubからインストール」を選択します。
  3. 以下のスキルフォルダのURLを貼り付けて確定します。
    https://github.com/Yakoub-ai/phaser4-gamedev/tree/main/skills/phaser-build
  4. スキルを利用したいチャットごとに、そのスキルを有効にしてください。
「プラグイン」→「スキル」→「スキルを追加」→「GitHubのURLから」を選択し、フォルダのURLを貼り付けて「続行」を押します。
2

別のAIエージェントにインストール

Agent Skills形式を読み取れるAIエージェントなら、このスキルを利用できます。フォルダをそのAIエージェントのスキルディレクトリにコピーしてください。

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-build .claude/skills/phaser-build
コピー後、新しいスキルを読み込むためにClaude Codeを再起動してください。

TypingMindで使用

TypingMindのチャットでPhaser Buildを有効にするだけで、あとはモデルが対応します。名前と説明がシステムプロンプトに含まれ、関連するリクエストがあると、モデルが指示の全文を自動で読み込みます。手動で呼び出す必要はなく、実際に使用されるまでトークンを消費しません。

関連するリクエストがあるとすぐに、モデルが自動的にPhaser Buildを読み込みます。

どのAIモデルでも利用可能

AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、Phaser Buildは作成時に想定されたモデルに縛られません。TypingMindに一度インストールすれば、ご自身のAPIキーを使って、GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama、またはご自身で実行するローカルモデルで利用できます。

  • 必要なときだけ読み込み

    システムプロンプトには名前と説明だけが含まれます。関連するリクエストが初めてあったときに指示を取得するため、スキルを使わない間は指示の読み込みにトークンを消費しません。

  • チャットの途中でモデルを切り替え

    スキルはコードではなく指示なので、モデルを切り替えてもそのまま使えます。次のモデルも同じSKILL.mdを読み込みます。

スキルの指示

モデルが読み込むSKILL.mdの内容です。スキルはモデルが従う指示なので、インストールする前に確認してください。

Phaser 4 Build and Deployment

Development Server

Start the dev server with hot reload:

bash
npm run dev

Opens at http://localhost:5173 (Vite default). Changes auto-reload in the browser.

Production Build

bash
npm run build     # Compiles TypeScript + bundles with Vite → dist/
npm run preview   # Serve the dist/ folder locally to test production build

Output in dist/ — static files ready for any web host.

Diagnose the Project

Run the validation script before building:

bash
bash scripts/validate-project.sh

The script checks for common issues automatically.

TypeScript Type Checking

bash
npx tsc --noEmit

Fix all type errors before shipping. Common Phaser 4 TypeScript issues:

Missing Phaser types:

json
// tsconfig.json — Phaser 4 resolves its own types via its exports map
{
  "compilerOptions": {
    "module": "ESNext",
    "moduleResolution": "bundler",
    "skipLibCheck": true
  }
}

Then import it explicitly in each file: import Phaser from 'phaser';

If you see TS2688: Cannot find type definition file for 'Phaser', the project is carrying the v3-era typeRoots + types: ["Phaser"] pair. Delete both keys — Phaser 4 ships a single types/phaser.d.ts, which is not a valid type-root package.

this.input.keyboard nullable:

typescript
// Wrong:
const cursors = this.input.keyboard.createCursorKeys();
// Correct:
const cursors = this.input.keyboard!.createCursorKeys();

sprite.body nullable:

typescript
// Wrong:
sprite.body.velocity.x
// Correct:
(sprite.body as Phaser.Physics.Arcade.Body).velocity.x
// Or:
sprite.body?.velocity.x

this.scene.get() returns base Scene type:

typescript
// Cast to specific scene class:
const game = this.scene.get('GameScene') as GameScene;

Common Build Errors

"Cannot find module 'phaser'"

bash
npm install phaser   # installs Phaser 4 (latest stable). Do NOT use phaser — that tag still points at 4.2.1

Asset 404 Errors (game loads but assets missing)

In Vite, assets must be in the public/ directory. They are served as-is at the root.

✅ public/assets/images/sky.png  → loads as 'assets/images/sky.png'
❌ src/assets/images/sky.png     → won't work with this.load.image()

Never import assets via ES imports for Phaser. Just reference the path string:

typescript
this.load.image('sky', 'assets/images/sky.png');  // ✅

"Phaser.Geom.Point is not a constructor"

v3 → v4 breaking change. Replace with Vector2:

typescript
// Old (v3):
const pt = new Phaser.Geom.Point(x, y);
// New (v4):
const pt = new Phaser.Math.Vector2(x, y);

"Math.PI2 is undefined"

v3 → v4 breaking change:

typescript
// Old (v3):
const angle = Math.PI2;        // was π (wrong!) in v3
// New (v4):
const angle = Math.TAU;        // π×2
const half = Math.PI_OVER_2;   // π/2

Black Screen on Launch

  1. Check browser console for errors (F12)
  2. Check for 404s in Network tab (missing assets)
  3. Verify scene is in GameConfig's scene: [] array
  4. Verify HTML has <div id="game-container"> if using parent: 'game-container'
  5. Try removing parent config to append to document.body directly

WebGL Context Lost

typescript
// Try Canvas renderer as fallback
const config = {
  type: Phaser.CANVAS,   // instead of Phaser.AUTO or Phaser.WEBGL
  // ...
};

Or add WebGL context loss recovery listener:

typescript
this.game.renderer.on('contextlost', () => {
  console.warn('WebGL context lost — attempting recovery');
});

Vite Configuration

typescript
// vite.config.ts
import { defineConfig } from 'vite';

export default defineConfig({
  base: './',             // IMPORTANT for itch.io and subdirectory deployment
  build: {
    outDir: 'dist',
    assetsDir: 'assets',
    minify: 'terser',
    rollupOptions: {
      output: {
        manualChunks: {
          phaser: ['phaser'],  // Bundle Phaser separately for caching
        },
      },
    },
  },
  server: {
    port: 5173,
  },
});

base: './' is critical for itch.io, GitHub Pages, and any subdirectory deployment. Without it, assets load from / (root) which breaks on subdirectory hosts.

Deployment Targets

This section covers the mechanics of getting a build onto a host. For deciding whether the game is ready — the readiness gate, versioning, store presence, launch day — see skills/phaser-release/.

itch.io

  1. npm run build
  2. Zip the dist/ folder contents (not the folder itself — zip what's inside)
  3. Upload the zip to itch.io → "Upload files" → HTML game
  4. Set "This file will be played in the browser"
  5. Check "SharedArrayBuffer support" if needed

GitHub Pages

yaml
# .github/workflows/deploy.yml
name: Deploy to GitHub Pages
on:
  push:
    branches: [main]
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
        with: { node-version: '18' }
      - run: npm ci
      - run: npm run build
      - uses: peaceiris/actions-gh-pages@v3
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          publish_dir: ./dist

Set base: '/repo-name/' in vite.config.ts for GitHub Pages (subdirectory).

Netlify / Vercel

Connect the git repo. Set:

  • Build command: npm run build
  • Output directory: dist

Both auto-deploy on push to main.

Capacitor (iOS/Android)

bash
npm install @capacitor/core @capacitor/cli @capacitor/ios @capacitor/android
npx cap init
npx cap add ios
npx cap add android
npm run build
npx cap sync
npx cap open ios    # Opens Xcode
npx cap open android  # Opens Android Studio

Performance Checklist Before Shipping

  • arcade: { debug: false } in GameConfig
  • Assets in texture atlases (not individual images)
  • Audio compressed (128kbps MP3 for BGM, 96kbps for SFX)
  • Object pooling for bullets/particles/enemies
  • maxParticles set on all particle emitters
  • npx tsc --noEmit passes with 0 errors
  • Tested in Chrome, Firefox, and Safari
  • Mobile tested (if targeting mobile)

For a detailed performance playbook (measurement-first prompting, per-frame allocation elimination, spatial grid, audio lazy-load, atlas packing, tween leak fixes), see skills/phaser-analyze/references/performance-playbook.md. Use /phaser-analyze for a full project audit before shipping if FPS is a concern.

Scripts

Run the project validator:

bash
bash scripts/validate-project.sh

The validator checks: Phaser version, tsconfig fields, presence of scene files, deprecated v3 API usage.

同梱ファイル

スキルが読み込まれている間、モデルは必要に応じてこれらを読み取ります。読み取り可能なファイルとして提供され、実行されることはありません。

よくある質問

AIスキル「Phaser Build」では何ができますか?

This skill should be used when the user asks to "build my game", "run my Phaser game", "start dev server", "deploy my game", "fix build errors", "configure Vite for Phaser", "game won't build", "TypeScript errors in Phaser", "publish to itch.io", or needs to compile, run, troubleshoot, or deploy a Phaser 4 project.

TypingMindでPhaser Buildを使うメリットは何ですか?

一度インストールすれば、どのモデルでも使えるからです。Phaser Buildはプロバイダー固有のコードではなく、通常のMarkdownで記述されているため、同じスキルをGPT-5、Claude、Gemini、Grok、ローカルモデルで利用できます。チャットの途中でモデルを切り替えても、そのまま使い続けられます。TypingMindは自分のAPIキーで動作するため、シート単位のサブスクリプションではなく、プロバイダーに直接料金を支払います。スキルとチャットは自分のストレージに保持されます。

TypingMindにPhaser Buildをインストールするにはどうすればよいですか?

TypingMindで「プラグイン」→「スキル」→「GitHubからインストール」を開き、https://github.com/Yakoub-ai/phaser4-gamedev/tree/main/skills/phaser-buildを貼り付けてください。TypingMindがSKILL.mdを読み込み、関連ファイルをまとめて、チャットごとに有効にできるスキルとしてインストールします。

Phaser Buildを使えるAIモデルはどれですか?

TypingMindに接続したどのモデルでも利用できます。AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、GPT、Claude、Gemini、Grok、ローカルモデルのいずれも、リクエストの内容がこのスキルの用途に合ったときに、このスキルを読み込めます。

Phaser Buildで使えるAIモデルの数に制限はありますか?

数に制限はありません。スキルに対応したモデルであれば、GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llamaなど、どのモデルでもPhaser Buildを利用できます。すべてTypingMind上で、自分のAPIキーを使って利用できます。

AIスキル「Phaser Build」は無料ですか?

Yakoub-aiがGitHubで公開しています。ライセンス条件はリポジトリでご確認ください。ご利用のAIプロバイダーに支払うのは、使用したトークンの料金だけです。

AIスキルとは何ですか?

AIスキルは、特定のタスクの実行方法をAIモデルに教える、再利用可能な指示のセットです。オープンなAgent Skills形式に従い、名前と説明を含むSKILL.mdファイルに加え、モデルが必要とするスクリプト、テンプレート、参照ファイルで構成されます。モデルはリクエストがスキルに合致したときだけ指示を読み込むため、インストール済みのスキルも、使うまでは費用がかかりません。

AIスキルは、プラグインやMCPサーバーとどう違いますか?

プラグインやMCPサーバーは、モデルが呼び出せる新しいツールを提供します。ツールとは、どこかで実行され、結果を返すコードです。一方、AIスキルは、タスクへの取り組み方、従うべき手順、望ましい出力の例といった知識や進め方をモデルに伝えます。スキルは通常のMarkdownで記述されているため、サーバー、APIキー、実行環境は不要で、どのモデルでも利用できます。

すべて見る

今すぐ自分専用のAIワークスペースを作成

ニュースレターに登録すると、新機能や今後のプレゼント企画のお知らせが届きます👇