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[]
parsers

All loader parsers registered

Record<string, PromiseAndParser>
promiseCache

Cache loading promises that ae currently active

Public Properties


parsers Loader.ts:197
parsers: LoaderParser[]

All loader parsers registered

promiseCache Loader.ts:21
promiseCache: Record<string, PromiseAndParser>

Cache loading promises that ae currently active

Public Methods


load Loader.ts:92
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);
Parameters:
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

Returns:
Type Description
Promise<{ [key: string]: any } | any>
reset Loader.ts:24
reset() → {void}

function used for testing

Returns:
Type Description
void
unload Loader.ts:158
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
Parameters:
Name Type Description
assetsToUnloadIn string | string[] | LoadAsset | LoadAsset[]

urls that you want to unload, or a single one!

Returns:
Type Description
Promise<void>

Powered by webdoc!