melonjs-loading-assets
What it does
It explains how to list a game's assets, preload them and read them back, including base paths and loading screens. It is for game developers organizing game files.
When to use it
- βWhen a developer needs to load all of a game's images and sounds before the first screen.
- βWhen a developer wants to know which asset type to use for a tile map or web font.
- βWhen a developer's assets fail to load because of a web address or cross-origin setting.
Skill link
https://github.com/melonjs/melonJS/blob/master/packages/melonjs/skills/melonjs-loading-assets/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agentβs skills folder.
Example of what to ask your AI
βSet up the asset list for my melonJS game with images, a Tiled map and a sound folder.β
5 new skills a week. 1 minute to read.
How it works
The skill shows the resource list format with a name, type and source for each file, then explains how to preload and read the assets back.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
Loading assets
The resource descriptor
Every asset is { name, type, src } plus type-specific extras:
import { loader } from "melonjs";
await loader.preload([
{ name: "tiles", type: "image", src: "data/img/tiles.png" },
{ name: "map1", type: "tmx", src: "data/map/map1.tmx" },
{ name: "tileset", type: "tsx", src: "data/map/tileset.tsx" },
{ name: "sfx", type: "audio", src: "data/sfx/" },
{ name: "font", type: "fontface", src: "data/font/PressStart2P.ttf" },
{ name: "atlas", type: "json", src: "data/img/atlas.json" },
]);
preload() has been awaitable since 19.8. The callback form still works and
takes a third argument to suppress the built-in loading screen:
loader.preload(resources, onLoaded, /* switchToLoadState */ false);
The type list
The type strings are melonJS-specific β this is not a generic loader:
| type | for |
|---|---|
"image" |
textures, sprite sheets, normal maps |
"json" |
data, texture-atlas descriptors, collision shapes from a shape editor |
"tmx" / "tsx" |
Tiled maps and external tilesets |
"audio" |
sound β src is a directory, see below |
"video" |
video textures |
"binary" |
raw data, bitmap font .fnt descriptors |
"fontface" |
web fonts (.ttf, .woff) |
"aseprite" |
Aseprite JSON + image |
"shader" |
GLSL/WGSL shader sources β src or inline via data |
"obj" / "mtl" |
Wavefront models and materials |
"gltf" / "glb" |
glTF scenes |
"js" |
scripts |
| any type you register | your own formats, and things you generate rather than download β see Custom asset types |
What belongs in the manifest β and what cannot
Preloading is not only for things with a URL. Three tiers, and the middle one is the one people miss.
After preloading, switch to a stage of your own. preload() puts you in
state.LOADING, and that stage is transitional: build your scene in the
callback and stay there, and nothing ever destroys it, so the built-in loading
screen's logo and progress bar remain on top of your game. See
melonjs-scenes-and-state.
1. Assets with a source. Everything in the type table above. Note "shader"
takes inline source as well as a src, via the data field:
import { myRamp } from "./myRamp"; // a GLSL fragment body, in your own module
loader.preload([
{ name: "ramp", type: "shader", data: myRamp },
]);
const fx = loader.getShader("ramp"); // shared, already compiled
This matters more than it looks. A ShaderEffect compiles its program in its
constructor, and compileProgram calls getProgramParameter(LINK_STATUS)
immediately after linkProgram β a blocking call that forces the driver to
finish. So building one during a scene costs that link on the frame it appears,
and building three identical ones costs it three times. Preloaded as an asset it
is compiled at load time, behind the loading screen, and the loader hands out a
shared instance (effect.shared === true), which is what stops one
renderable's teardown freeing it out from under the others. clone() does NOT
help here β it constructs a new effect, and therefore links a new program.
2. Derived assets β build once, before the first stage. Canvases you bake,
NoiseTexture2d, TextureAtlas: none of the built-in types describes these,
and they must not be rebuilt per scene either. The renderer's texture cache is
keyed by the image object, so a freshly baked canvas is a brand new GPU
texture with a new mip chain β rebuild one per stage and a title β play β
game-over cycle uploads four copies of the same pixels. Build each once and
share it from a module the scenes read from, the way the platformer example
builds its TextureAtlas.
Where you build it depends on what it costs. A gradient or a palette strip is
well under a millisecond: build it after preload resolves. A bake that takes
real time β procedural noise is the usual one: Earth Defender's sky, two fractal
simplex fields over a 512Β² tile, takes about 200ms on a desktop β belongs
inside the preload as an asset type of your
own (Custom asset types). It then runs behind the loading
screen and counts on the progress bar. Built on stage entry instead, it lands on
the frame the scene is assembled, and with a transition running that frame is a
black screen.
**3. The engine's own shader programs β warmed for you, si
FAQ
What is a resource descriptor?
It is an entry with a name, a type and a source path for one file.
Is the sound source a file or a folder?
For audio, the source is a folder prefix, not a single file name.
Can I hide the loading screen?
Yes. The skill mentions a setting in the older callback form that suppresses the built-in loading screen.
Details
Original description by the author
Use this skill for loading and managing game assets in melonJS β the resource descriptor format, the full asset type list, preload versus load, retrieving loaded assets, base URLs and cross-origin settings, and the loading screen. Triggers on: loader, loader.preload, loader.load, resources, getImage, getJSON, getTMX, getGLTF, getVideo, getFont, setBaseURL, setOptions, crossOrigin, withCredentials, credentials, cookies, authenticated assets, CORS, asset, preload, LOADER_COMPLETE, loading screen, unload, setParser, custom asset type, generated texture, procedural texture.
repo: melonjs/melonJS
Popularity
- GitHub stars
- 6.4k
- Ranking position
- #14206
- License
- MIT
- Updated
- 11/2/2026
Comments
- β¦
More skills from this repository
melonjs-20-migration
6.4kHelps your agent write melonJS game code for version 20 and avoid outdated methods from older versions, such as the required async startup.
melonjs-3d-assets
6.4kHelps your agent load 3D models such as glTF, GLB and OBJ files into a melonJS browser game, with scale and lighting options.
melonjs-3d
6.4kHelps your agent build 3D or 2.5D scenes in a melonJS browser game, covering cameras, meshes, lights and depth, using the engine's own axis rules.
melonjs-audio
6.4kHelps your agent add sound effects and music to a melonJS game, including audio setup, background tracks, volume control and spatial sound.
Similar skills
diffs
394kLets your agent produce a real, shareable diff of edits as a viewer link or image file, instead of a hand-written summary.
coding-agent
394kHelps your agent hand a larger coding job to Codex, Claude Code, or OpenCode as a background worker, then check on its progress.
gh-issues
394kHelps your agent find GitHub issues, pick the ones to work on, and open pull requests with fixes, including follow-up on review comments.