본문으로 건너뛰기
Skillpedia
일반 코딩6.4k · #14211

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가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/melonjs/melonJS/blob/master/packages/melonjs/skills/melonjs-plugins/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

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 an app reference, but it defaults to game — whichever Application most recently finished init(), since that is where game is assigned. On a multi-application page, pass the app explicitly through the constructor args: plugin.register(DebugPanelPlugin, "debugPanel", input.KEY.S, myApp).
  • BasePlugin.version is a floor, not an identity. It declares the minimum melonJS version the plugin needs, and register throws Plugin 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

자주 묻는 질문

플러그인을 등록할 때 왜 오류가 나나요?

플러그인 레지스트리는 전역이라서 같은 이름을 두 번 등록할 수 없다고 스킬은 말합니다.

물리 엔진도 플러그인인가요?

아니요. 스킬은 물리 어댑터는 플러그인으로 등록하지 않고, 앱을 만들 때 설정한다고 말합니다.

어떤 플러그인을 언급하나요?

디버그 패널, 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.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬