ImageAsset class

A reference to an image file shared with the Oooh platform.

Signature:

export declare class ImageAsset extends AbstractModuleAsset 

Extends: AbstractModuleAsset

Methods

MethodModifiersDescription
delete()Delete the image asset.
getImageUrl()Returns an Object URL pointing to a Blob of the image file's contents, for assets created by the AssetManager. This Blob is stored in memory; use AbstractModuleAsset.dispose() if you no longer need it. For remotely hosted assets, returns a regular https:// URI.

ImageAsset.delete() method

Delete the image asset.

Signature:

delete(): void;

Returns:

void

Remarks

Either this or AssetManager.addToOutput() must be called for every image asset created by the module

ImageAsset.getImageUrl() method

Returns an Object URL pointing to a Blob of the image file's contents, for assets created by the AssetManager. This Blob is stored in memory; use AbstractModuleAsset.dispose() if you no longer need it. For remotely hosted assets, returns a regular https:// URI.

Signature:

getImageUrl(): Promise<string>;

Returns:

Promise<string>

A readable URL

Example

// Use the Object URL as a Phaser texture by supplying an html <image>
image = new Image();
image.src = await imageAsset.getImageUrl();
await new Promise(resolve =\> image.addEventListener('load', resolve)); // simple wait for load
this.textures.addImage('pic', image); // See TextureManager.addImage()
this.add.image(0, 0, 'pic'); // Use the texture by key