Skip to content

Class: AssetLoader

Handles loading and storage of game assets.

Source: core/AssetLoader.js, line 9


Constructor

new AssetLoader()

Creates an instance of AssetLoader.

Description: Handles loading and storage of game assets.

Source: core/AssetLoader.js, line 9


Members

loadedCount

Type: number

Source: core/AssetLoader.js, line 20


totalCountInCurrentBatch

Type: number

Source: core/AssetLoader.js, line 25


Methods

get(name)

Retrieves a pre-loaded asset from the cache.

Parameters:

NameTypeDescription
namestringThe name/key of the asset to retrieve.

Returns: HTMLImageElement | object | AudioBuffer | undefined The cached asset, or undefined if not found.

Source: core/AssetLoader.js, line 407


getLoadingCount()

Gets the current number of assets being loaded.

Returns: number

Source: core/AssetLoader.js, line 439


isDoneLoading()

Checks if all assets currently being loaded have finished loading.

Returns: boolean True if loadedCount is 0, false otherwise.

Source: core/AssetLoader.js, line 431


loadAll(batchId?)

Starts loading all queued assets.

Parameters:

NameTypeAttributesDefaultDescription
batchIdstringoptional'defaultBatch'An optional identifier for this loading batch.

Returns: Promise<Map<string, any>> A promise that resolves with a map of successfully loaded assets in this batch, or rejects if any critical asset fails (though individual errors are also emitted).

Source: core/AssetLoader.js, line 311


queueAudio(name, path, group?)

Queues an audio file for loading.

Parameters:

NameTypeAttributesDefaultDescription
namestringA unique name to identify the asset.
pathstringThe path to the audio file.
groupstringoptional'global'An optional group name for the asset.

Returns: this

Source: core/AssetLoader.js, line 97


queueImage(name, path, group?)

Queues an image for loading.

Parameters:

NameTypeAttributesDefaultDescription
namestringA unique name to identify the asset.
pathstringThe path to the image file.
groupstringoptional'global'An optional group name for the asset.

Returns: this

Source: core/AssetLoader.js, line 65


queueJSON(name, path, group?)

Queues a JSON file for loading.

Parameters:

NameTypeAttributesDefaultDescription
namestringA unique name to identify the asset.
pathstringThe path to the JSON file.
groupstringoptional'global'An optional group name for the asset.

Returns: this

Source: core/AssetLoader.js, line 81

Released under the MIT License (Placeholder).