PIXI.AssetLoader
class AssetLoader
The Loader is responsible for loading all assets, such as images, spritesheets, audio files, etc. It does not do anything clever with URLs - it just loads stuff! Behind the scenes all things are cached using promises. This means it's impossible to load an asset more than once. Through the use of LoaderParsers, the loader can understand how to load any kind of file!
It is not intended that this class is created by developers - its part of the Asset class This is the second major system of PixiJS' main Assets class
Constructor
new PIXI.AssetLoader() → {}
Summary
Properties from AssetLoader
LoaderParser[] |
All loader parsers registered |
Record<string, PromiseAndParser> |
Cache loading promises that ae currently active |
Methods from AssetLoader
Promise<{ [key: string]: any } | any> |
|
void |
function used for testing |
Promise<void> |
|
Public Properties
promiseCache: Record<string, PromiseAndParser>
Cache loading promises that ae currently active
Public Methods
load(assetsToLoadIn: string | string[] | LoadAsset | LoadAsset[], onProgress: (progress: number) => void) → {Promise<{ [key: string]: any } | any>}
Loads an asset(s) using the parsers added to the Loader.
// single asset:
const asset = await Loader.load('cool.png');
console.log(asset);
// multiple assets:
const assets = await Loader.load(['cool.png', 'cooler.png']);
console.log(assets);
Name | Type | Attributes | Description |
---|---|---|---|
assetsToLoadIn | string | string[] | LoadAsset | LoadAsset[] |
urls that you want to load, or a single one! |
|
onProgress | (progress: number) => void |
<optional> |
a function that gets called when the progress changes |
Type | Description |
---|---|
Promise<{ [key: string]: any } | any> |
unload(assetsToUnloadIn: string | string[] | LoadAsset | LoadAsset[]) → {Promise<void>}
Unloads an asset(s). Any unloaded assets will be destroyed, freeing up memory for your app. The parser that created the asset, will be the one that unloads it.
// single asset:
const asset = await Loader.load('cool.png');
await Loader.unload('cool.png');
console.log(asset.destroyed); // true
Name | Type | Description |
---|---|---|
assetsToUnloadIn | string | string[] | LoadAsset | LoadAsset[] |
urls that you want to unload, or a single one! |
Type | Description |
---|---|
Promise<void> |