AssetManager

platypus. AssetManager

new AssetManager()

This class is instantiated by Platypus at platypus.assetCache to track assets: loading assets needed for particular layers and unloading assets once they're no longer needed.

Source:

Methods

delete(id) → {Boolean}

This method removes an asset from memory if it's the last needed instance of the asset.

Source:
Parameters:
Name Type Description
id *
Returns:
Type:
Boolean

Returns true if asset was removed from asset cache.

get(id) → {Object}

Returns a loaded instance of a given asset.

Source:
Parameters:
Name Type Description
id *
Returns:
Type:
Object

Returns the asset if defined.

getFileId(path) → {String}

Returns id for given path.

Source:
Parameters:
Name Type Description
path *
Returns:
Type:
String

Returns id generated from path.

has(id) → {Object}

Returns whether a given asset is currently loaded by the AssetManager.

Source:
Parameters:
Name Type Description
id *
Returns:
Type:
Object

Returns true if the asset is loaded and false if not.

load(list, one, all)

Loads a list of assets.

Source:
Parameters:
Name Type Description
list Array

A list of assets to load.

one function

This function is called as each asset is loaded.

all function

This function is called once all assets in the list are loaded.

set(id, value, count)

Sets a mapping between an id and a loaded asset. If the mapping already exists, simply increment the count for a given id.

Source:
Parameters:
Name Type Description
id *
value *

The loaded asset.

count Number

The number of assets needed.

unload(list)

Unloads a list of assets. This is identical to passing each item in the list to .delete().

Source:
Parameters:
Name Type Description
list Array

A list of assets to unload.