melonjs-getting-started
Agent skill frommelonjs/melonJS
Use this skill when starting or bootstrapping a melonJS game, creating the Application, choosing a renderer, or setting up the first scene. Covers the mandatory async init, the world container, adding renderables, and the WebGPU/WebGL 2/Canvas fallback. Triggers on: melonjs, new Application, app.init, app.world, video.AUTO, video.WEBGL, video.CANVAS, Stage, state.change, getting started, bootstrap.
How to install melonjs-getting-started
install melonjs-getting-started
# install the melonJS pack with the skills CLI
npx skills add melonjs/melonJS# or add only this skill to Claude Code: copy the folder
packages/melonjs/skills/melonjs-getting-started/
# into
~/.claude/skills/melonjs-getting-started/ (all projects)
.claude/skills/melonjs-getting-started/ (one project)
1# Getting started with melonJS23> Bootstrapping a melonJS 20.x game: the `Application` lifecycle, the mandatory4> `await app.init()`, the world container, and what the renderer fallback means5> for feature availability.67**Applies to:** melonJS 20.x. Older major versions differ — see the8`melonjs-20-migration` skill.910## The bootstrap1112`Application` construction is synchronous but **initialisation is not**. `init()`13returns a promise and must be awaited before building any renderable, loading14assets, or entering a scene.1516```js17import { Application, Text } from "melonjs";1819const app = new Application(1218, 562, {20 parent: "screen", // id of the DOM element to mount into21 scale: "auto",22 backgroundColor: "#202020",23});24await app.init(); // ← REQUIRED. Nothing below works without it.2526app.world.addChild(27 new Text(609, 281, {28 font: "Arial",29 size: 160,30 fillStyle: "#FFFFFF",31 textAlign: "center",32 textBaseline: "middle",33 text: "Hello World !",34 }),35);36```3738**This is the single most common thing to get wrong.** On 19.x the constructor39called `init(width, height, options)` for you; on 20.x `init()` takes no40arguments and calling — and awaiting — it is your job. Nothing that follows41names the missing call. The constructor does build `app.world`, so adding a42plain renderable succeeds and simply never draws — no canvas is appended and the43…
Excerpt shown under the repository's MIT license.
