the asset type ("audio", "video", "binary", "image",
"json", "js", "tmx", "tsx", "tilemap", "spritefusion", "ldtk", "fontface",
"aseprite", "shader", "obj", "mtl", "gltf", "glb", or a custom type), or "*"
Optionalurl: string = "./"
the base URL, ending with a /
// a relative path for the images
loader.setBaseURL("image", "data/img/");
// so that a descriptor names the file alone: loads data/img/player.png
await loader.preload([{ name: "player", type: "image", src: "player.png" }]);
// one folder for the maps of every editor
for (const type of ["tmx", "tsx", "tilemap", "spritefusion", "ldtk"]) {
loader.setBaseURL(type, "data/map/");
}
await loader.preload([
{ name: "cave", type: "tmx", src: "cave.tmx" },
{ name: "tower", type: "spritefusion", src: "tower/map.json" }, // and data/map/tower/spritesheet.png
]);
// or an absolute URL for every 2D asset type at once
loader.setBaseURL("*", "https://cdn.example.com/");
Set the base URL prepended to the
srcof every asset of a type, so the descriptors need not repeat it. Applies to assets loaded from then on; a data URIsrcis never prefixed."*"sets it for every built-in type exceptobj,mtl,gltfandglb, which resolve their own references (amap_Kdtexture, a glTF buffer) relative to their file and would be prefixed twice: set those one by one. Custom types registered with setParser are not covered by"*"either.What a map brings with it (a Sprite Fusion map's spritesheet, an LDtk project's level files and images) is found next to the map's file, wherever the base URL put it: nothing to set for those.