मुख्य सामग्री पर जाएँ
Skillpedia
सामान्य कोडिंग6.4k · #14206

melonjs-loading-assets

यह क्या करती है

यह बताती है कि गेम के assets की सूची कैसे बनाएँ, उन्हें पहले से लोड करें और वापस पढ़ें, जिसमें base paths और loading screens शामिल हैं। यह गेम फ़ाइलें व्यवस्थित करने वाले गेम डेवलपर्स के लिए है।

कब इस्तेमाल करें

  • ✓जब डेवलपर को पहली स्क्रीन से पहले गेम की सारी इमेज और साउंड लोड करने हों।
  • ✓जब डेवलपर जानना चाहे कि टाइल मैप या वेब फ़ॉन्ट के लिए कौन सा asset प्रकार इस्तेमाल करें।
  • ✓जब डेवलपर के assets वेब पते या cross-origin सेटिंग की वजह से लोड न हों।

Skill का लिंक

https://github.com/melonjs/melonJS/blob/master/packages/melonjs/skills/melonjs-loading-assets/SKILL.md

इसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।

कैसे इस्तेमाल करें

सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।

पेस्ट करने के लिए तैयार मैसेज

इस skill से मेरी मदद करो: https://github.com/melonjs/melonJS/blob/master/packages/melonjs/skills/melonjs-loading-assets/SKILL.md इस लिंक की SKILL.md फ़ाइल पढ़ो और मेरे काम में उसके निर्देशों का पालन करो।
क्या आप चाहते हैं कि आपका AI ऐसी skills खुद ढूँढे?मुफ़्त Skillpedia MCP इंस्टॉल करें: बस एक लाइन, और हर काम से पहले यह 15,000+ skills में खोजता है।1 मिनट में इंस्टॉल करें →

AI से क्या माँगें: उदाहरण

“मेरे melonJS गेम के लिए assets की सूची सेट कीजिए, जिसमें इमेज, Tiled मैप और एक साउंड फ़ोल्डर हो।”

हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।

यह कैसे काम करती है

यह स्किल हर फ़ाइल के लिए नाम, प्रकार और स्रोत वाली resource सूची का फ़ॉर्मेट दिखाती है, फिर बताती है कि assets को पहले से लोड करके बाद में कैसे पढ़ें।

तकनीकी सामग्री (मूल SKILL.md)

लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे 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

अक्सर पूछे जाने वाले सवाल

resource descriptor क्या है?

यह एक फ़ाइल के लिए नाम, प्रकार और स्रोत पथ वाली प्रविष्टि है।

साउंड का स्रोत फ़ाइल है या फ़ोल्डर?

ऑडियो के लिए स्रोत एक फ़ोल्डर प्रिफ़िक्स है, एक फ़ाइल नाम नहीं।

क्या मैं लोडिंग स्क्रीन छिपा सकता हूँ?

हाँ। स्किल पुराने callback रूप की एक सेटिंग का ज़िक्र करती है जो अंतर्निहित लोडिंग स्क्रीन दबा देती है।

जानकारी

लेखक का मूल विवरण

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

लोकप्रियता

GitHub स्टार
6.4k
रैंकिंग में स्थान
#14206
लाइसेंस
MIT
अपडेट की गई
2/11/2026

क्या यह skill काम की है?

0

लॉग इन करें वोट करने के लिए।

कमेंट

  • …

इस repository की और skills

melonjs-20-migration

6.4k

आपके एजेंट को melonJS वर्शन 20 के लिए गेम कोड लिखने में मदद करती है और पुराने वर्शन के आउटडेटेड तरीकों से बचाती है, जैसे ज़रूरी async स्टार्टअप।

कोडिंगसामान्य कोडिंग

melonjs-3d-assets

6.4k

आपके एजेंट को glTF, GLB और OBJ जैसे 3D मॉडल melonJS ब्राउज़र गेम में लोड करने में मदद करती है, scale और lighting विकल्पों के साथ।

कोडिंगसामान्य कोडिंग

melonjs-3d

6.4k

आपके एजेंट को melonJS ब्राउज़र गेम में 3D या 2.5D दृश्य बनाने में मदद करती है, जिसमें कैमरा, मेश, लाइट और गहराई शामिल हैं, इंजन के अपने axis नियमों के साथ।

कोडिंगसामान्य कोडिंग

melonjs-audio

6.4k

आपके एजेंट को melonJS गेम में साउंड इफ़ेक्ट और संगीत जोड़ने में मदद करती है, जिसमें ऑडियो सेटअप, बैकग्राउंड ट्रैक, वॉल्यूम नियंत्रण और स्थानिक ध्वनि शामिल हैं।

कोडिंगसामान्य कोडिंग

मिलती-जुलती skills