Link Search Menu Expand Document

AssetManager

A utility class for storage and access to Assets.

Constructor

 assetManager = AssetManager(client)

Arguments

Name Type Description
client Client The allonet client to handle assets for

Returns

Nothing


Methods

AssetManager:add (asset, manage)

Adds an Asset to the AssetManager

 AssetManager:add(asset, manage)

Arguments

Name Type Description
asset Asset The Asset to add
manage bool If set to true, the AssetManager will hold on to the asset for you. If set to false, it will only serve the asset as long as you keep a reference to it.

Returns

Nothing


AssetManager:remove (asset)

Removes an Asset from the AssetManager

 AssetManager:remove(asset)

Arguments

Name Type Description
asset Asset The Asset to remove

Returns

Nothing


AssetManager:get (name)

Get an Asset with the corresponding name. Returns nil if no matching Asset is found.

 AssetManager:get(name)

Arguments

Name Type Description
name string The name of the requested string

Returns

Type Description
Asset The corresponding Asset

AssetManager:all ()

Gets all Assets currently held by the AssetManager.

 AssetManager:all()

Arguments

None

Returns

Type Description
Table All assets held by the AssetManager

AssetManager:count ()

Get the number of Assets currently held by the AssetManager.

 AssetManager:count()

Arguments

None

Returns

Type Description
number The number of assets held by the AssetManager

AssetManager:load (name, callback)

Start to load an asset. Callback will be called with the Asset when loading is complete, or with nil if failed.

 AssetManager:load(name, callback)

callback: function(name, asset_or_nil) returns true if the asset is loading. returns false if asset was found in cache

Arguments

Name Type Description
name ???  
callback ???  

Returns

Nothing