Skip to main content

@palco-2d/core / AssetHandler

Class: AssetHandler

Defined in: src/AssetHandler/AssetHandler.ts:16

AssetHandler is a singleton class that handles loading and storing assets. That can be easily accessed by other classes to get the loaded asset.

Constructors

new AssetHandler()

new AssetHandler(): AssetHandler

Returns

AssetHandler

Properties

assets

static assets: object = {}

Defined in: src/AssetHandler/AssetHandler.ts:17

Index Signature

[key: string]: SupportedAssetsType

Methods

getAsset()

static getAsset<T>(key): T

Defined in: src/AssetHandler/AssetHandler.ts:19

Type Parameters

T extends SupportedAssetsType

Parameters

key

string

Returns

T


loadFont()

static loadFont(name, path): Promise<FontFace>

Defined in: src/AssetHandler/AssetHandler.ts:120

Load a font from the given path and add to document.fonts.

Parameters

name

string

path

string

Returns

Promise<FontFace>


loadPng()

static loadPng(path): Promise<HTMLImageElement>

Defined in: src/AssetHandler/AssetHandler.ts:27

Load a png image from the given path.

Parameters

path

string

Path to the png image.

Returns

Promise<HTMLImageElement>


loadSVG()

static loadSVG(path): Promise<SVGAsset[]>

Defined in: src/AssetHandler/AssetHandler.ts:45

Load a svg image from the given path. it scans the svg for path elements then store the stringified coordinates in an array, to be accessed later by the SVGImage entity.

Parameters

path

string

Path to the svg image.

Returns

Promise<SVGAsset[]>


loadTileMap()

static loadTileMap(path): Promise<TileMapType>

Defined in: src/AssetHandler/AssetHandler.ts:106

Load a tilemap from the given path.

Parameters

path

string

Path to the tilemap json file.

Returns

Promise<TileMapType>