melonjs-plugins
できること
このガイドは、melonJSのプラグインとアダプターを登録して使う方法を説明します。それらが物理の設定とどう違うかも扱います。melonJSのプロジェクトを拡張する開発者向けです。
使う場面
- ✓開発者が、melonJSのゲームにデバッグパネルを追加したいとき。
- ✓開発者が、ゲームにSpineのスケルタルアニメーションやタッチ操作を入れたいとき。
- ✓開発者が、プラグインがすでに登録されているというエラーを受け取ったとき。
スキルのリンク
https://github.com/melonjs/melonJS/blob/master/packages/melonjs/skills/melonjs-plugins/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“私のmelonJSのゲームにデバッグパネルのプラグインを追加し、アプリで動くことを確認してください。”
毎週5つの新しいスキル。1分で読めます。
仕組み
このスキルはAIに、アプリが起動した後で各プラグインを一度だけ登録し、ページに複数のアプリがある場合は正しいアプリを明示的に渡すよう指示します。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
Plugins and adapters
Two different mechanisms
This trips people up, so it is worth stating first:
| how it is installed | |
|---|---|
| Plugins | plugin.register(Class, name?, ...args) — after await app.init() |
| Physics adapters | an Application setting (physic:), before init() |
// the adapter is chosen at construction …
const app = new Application(800, 600, {
parent: "screen",
physic: new PlanckAdapter({ gravity, pixelsPerMeter }),
});
// … the plugin is registered once the renderer exists
await app.init();
plugin.register(DebugPanelPlugin, "debugPanel");
register in detail
plugin.register(PluginClass, "name", ...constructorArgs);
plugin.cache.name; // the instance
plugin.get(PluginClass); // by class — or by registered name string
- The name is optional — it falls back to the class name.
- The registry is global, not per-application. It is a module-level object,
so registering the same name twice throws
plugin <name> already registered. A plugin instance does hold anappreference, but it defaults togame— whichever Application most recently finishedinit(), since that is wheregameis assigned. On a multi-application page, pass the app explicitly through the constructor args:plugin.register(DebugPanelPlugin, "debugPanel", input.KEY.S, myApp). BasePlugin.versionis a floor, not an identity. It declares the minimum melonJS version the plugin needs, andregisterthrowsPlugin version mismatch, expected: <floor>, got: <engine>when the running engine is older. That gate is the real enforcement — a peer-dependency range only warns at install time, and not at all for CDN or pre-bundled use. If you see that error, upgrade the engine or pin an older plugin. The check runs after the instance is constructed, so a plugin whose constructor has side effects will already have run them when it throws.
Register after await app.init(): a plugin binds to an Application and reads
renderer and frame state that does not exist before init.
The official plugins
@melonjs/debug-plugin
An in-game panel — frame time, draw and object counts — plus toggles for hitbox/bounding-box overlays, velocity vectors and quadtree visualisation. The first thing to reach for when something is slow or a collision is not landing where you expect.
import { DebugPanelPlugin } from "@melonjs/debug-plugin";
plugin.register(DebugPanelPlugin, "debugPanel"); // default toggle key: S
@melonjs/tiled-inflate-plugin
Required, not optional, for Tiled maps using gzip, zlib or zstd layer
compression. It installs the inflate hook TMXUtils calls; without it a
compressed .tmx fails to parse — a map that opens fine in Tiled and refuses to
load in melonJS is nearly always this.
import { TiledInflatePlugin } from "@melonjs/tiled-inflate-plugin";
plugin.register(TiledInflatePlugin);
@melonjs/spine-plugin
Spine 4.x skeletal animation as a melonJS renderable, on all three backends. This is the answer for deforming animated characters — glTF import does not read vertex skinning. It also registers a Tiled object class, so Spine skeletons can be placed from a map.
@melonjs/gamepad-plugin
On-screen touch controls, reported as a gamepad: one or two sticks and any
number of buttons, drawn over the game and read by the engine as a pad in a
gamepad slot. The game's bindGamepad bindings drive it unchanged, so one set
of bindings covers a real pad and a touch screen.
import { GamepadPlugin } from "@melonjs/gamepad-plugin";
plugin.register(GamepadPlugin, "gamepad", {
buttons: [{ label: "A" }, { label: "B" }],
});
// plugin.cache.gamepad.visible — showing, to word prompts ("tap" or a key)
Shown on touch screens by default (enabled), hidden while a real pad is in
use. The left stick also presses the D-pad; a button can press a key instead
of a pad button. Since 1.1 a stick or button can be floating (shows up
under the finger anywhere in its area), hideAtRest (drawn only while
held), and a stick can take a tap (a quick touch that does not steer presses
a key or button) — so the mobile layouts, two thumbs or one thumb with
tap-to-act, need no code of their own. See melonjs-input for the bindings,
the layouts and the overlap rules.
@melonjs/capacitor-plugin
Bridges Capacitor's native lifecycle and hardware-back events into the eng
よくある質問
プラグインの登録でエラーが出るのはなぜですか?
プラグインのレジストリはグローバルなので、同じ名前を2回登録できないとスキルは述べています。
物理エンジンもプラグインですか?
いいえ。物理のアダプターはプラグインとして登録されるのではなく、アプリの作成時に設定するとスキルは述べています。
どのプラグインに触れていますか?
デバッグパネル、Spineアニメーション、圧縮マップの対応、タッチ操作、Capacitorのパッケージ化に触れています。
詳細
作者による元の説明
Use this skill when adding a melonJS plugin or adapter — the debug panel, Spine skeletal animation, compressed Tiled map support, on-screen touch controls, Capacitor packaging — or when writing your own plugin. Covers plugin.register and its version gate, plugin.cache, plugin.patch, and why physics adapters are not plugins. Triggers on: plugin, plugin.register, plugin.cache, plugin.get, plugin.patch, BasePlugin, debug-plugin, DebugPanelPlugin, SpinePlugin, TiledInflatePlugin, GamepadPlugin, gamepad-plugin, touch controls, virtual joystick, floating joystick, floating button, CapacitorPlugin, a
repo: melonjs/melonJS
人気
- GitHubのスター
- 6.4k
- ランキング
- #14211
- ライセンス
- MIT
- 更新日
- 2026/11/2
コメント
- …
このリポジトリの他のスキル
melonjs-20-migration
6.4kエージェントが、バージョン20のmelonJSゲームのコードを書き、必要な非同期の起動など、古いバージョンの古いメソッドを避けられるよう支援します。
melonjs-3d-assets
6.4kエージェントが、glTF、GLB、OBJなどの3DモデルをmelonJSのブラウザゲームに読み込み、スケールとライティングのオプションを使えるよう支援します。
melonjs-3d
6.4kエージェントが、エンジン独自の軸のルールを使い、カメラ、メッシュ、ライト、奥行きを含めて、melonJSのブラウザゲームで3Dまたは2.5Dのシーンを作れるよう支援します。
melonjs-audio
6.4kエージェントが、音声の設定、背景の音楽、音量の制御、空間的な音響を含め、melonJSのゲームに効果音と音楽を追加できるよう支援します。
似ているスキル
diffs
394k編集内容の実際の共有可能な差分を、手書きの要約ではなく、ビューアーのリンクや画像ファイルとして作成するようエージェントを支援します。
coding-agent
394kCodex、Claude Code、OpenCodeに大きめのコーディング作業をバックグラウンドのワーカーとして渡し、その進捗を確認するようエージェントを支援します。
gh-issues
394kGitHubのイシューを探し、取り組むものを選び、修正を含むプルリクエストを開くようエージェントを支援します。レビューコメントへの対応も含みます。