Manages loading and retrieval of game assets including images, fonts, audio files, videos and JSON data. Provides methods to load assets asynchronously and check their loading status. Assets can be referenced by URL or optional name identifiers.
this.assetManager.loadImage("image.png");this.assetManager.loadAudio("audio.ogg");this.assetManager.loadVideo("video.mp4");this.assetManager.loadFont("custom-font", "custom-font.ttf");this.assetManager.loadJson("data.json");const imageElement = this.assetManager.getImage("image.png");const audioElement = this.assetManager.getAudio("audio.ogg");const videoElement = this.assetManager.getVideo("video.mp4");const fontFace = this.assetManager.getFont("custom-font");const jsonData = this.assetManager.getJson("data.json");if (this.assetManager.getAssetsLoaded()) { // do something when assets are loaded} Copy
this.assetManager.loadImage("image.png");this.assetManager.loadAudio("audio.ogg");this.assetManager.loadVideo("video.mp4");this.assetManager.loadFont("custom-font", "custom-font.ttf");this.assetManager.loadJson("data.json");const imageElement = this.assetManager.getImage("image.png");const audioElement = this.assetManager.getAudio("audio.ogg");const videoElement = this.assetManager.getVideo("video.mp4");const fontFace = this.assetManager.getFont("custom-font");const jsonData = this.assetManager.getJson("data.json");if (this.assetManager.getAssetsLoaded()) { // do something when assets are loaded}
Returns TRUE if the assets are loaded
TRUE or FALSE
Retrieves an audio asset
The asset URL
The HTML Audio element
The asset name
Retrieves a font asset
The font family name
The Font element
Retrieves an image asset
The HTML Image element
Retrieves a json asset
The JSON object
Retrieves a video asset
The HTML Video element
Loads an audio asset
Optional
The asset name [optional]
The HTML Audio element created
Loads a font asset
The FontFace object created
Loads an image asset
The HTML Image element created
Loads a JSON asset
Promise<Record<string, any>>
Loads an video asset
The HTML Video element created
Manages loading and retrieval of game assets including images, fonts, audio files, videos and JSON data.
Provides methods to load assets asynchronously and check their loading status.
Assets can be referenced by URL or optional name identifiers.
Example