class Assets
package kha
Static variables
Static methods
staticloadBlobFromPath(path:String, done:Blob ‑> Void, ?failed:AssetError ‑> Void, ?pos:PosInfos):Void
staticloadEverything(callback:() ‑> Void, ?filter:(item:AssetData) ‑> Bool, ?uncompressSoundsFilter:(soundItem:AssetData) ‑> Bool, ?failed:(err:AssetError) ‑> Void):Void
Loads all assets which were detected by khamake. When running khamake (doing so is Kha's standard build behavior) it creates a files.json in the build/{target}-resources directoy which contains information about all assets which were found.
The callback
parameter is always called after loading, even when some or all assets had failures.
An optional callback parameter failed
is called for each asset that failed to load.
The filter parameter can be used to load assets selectively. The Dynamic parameter describes the asset, it contains the very same objects which are listed in files.json.
Additionally by default all sounds are decompressed. The uncompressSoundsFilter can be used to avoid that. Uncompressed sounds can still be played using Audio.stream which is recommended for music.
staticloadFontFromPath(path:String, done:Font ‑> Void, ?failed:AssetError ‑> Void, ?pos:PosInfos):Void
staticloadImage(name:String, done:Image ‑> Void, ?failed:AssetError ‑> Void, ?pos:PosInfos):Void
Loads an image by name which was preprocessed by khamake.
Parameters:
name | The name as defined by the khafile. |
---|---|
done | A callback. |
staticloadImageFromPath(path:String, readable:Bool, done:Image ‑> Void, ?failed:AssetError ‑> Void, ?pos:PosInfos):Void
Loads an image from a path. Most targets support PNG and JPEG formats.
Parameters:
path | The path to the image file. |
---|---|
readable | If true, a copy of the image will be kept in main memory for image read operations. |
done | A callback. |