Skip to content
ClassAssets & Loading@public

FlxAssets

Typed, explicitly asynchronous facade over PixiJS v8 Assets.

ts
export declare class FlxAssets

Constructors

ts
constructor(backend?: FlxAssetBackend)

Constructs a new instance of the FlxAssets class

ParameterTypeDescription
backendFlxAssetBackend-

Methods

add()

ts
add(descriptor: FlxAssetDescriptor | FlxAssetDescriptor[]): this

Parameters:

ParameterTypeDescription
descriptorFlxAssetDescriptor | FlxAssetDescriptor[]-

Returns: this

addBundle()

ts
addBundle(name: string, assets: FlxAssetDescriptor[]): this

Parameters:

ParameterTypeDescription
namestring-
assetsFlxAssetDescriptor[]-

Returns: this

backgroundLoad()

ts
backgroundLoad(ids: string | string[]): Promise<void>

Parameters:

ParameterTypeDescription
idsstring | string[]-

Returns: Promise<void>

backgroundLoadBundle()

ts
backgroundLoadBundle(names: string | string[]): Promise<void>

Parameters:

ParameterTypeDescription
namesstring | string[]-

Returns: Promise<void>

failureFor()

ts
failureFor(id: string): FlxAssetLoadError | undefined

Parameters:

ParameterTypeDescription
idstring-

Returns: FlxAssetLoadError | undefined

static fromContext()

ts
static fromContext(context: FlxContext): FlxAssets | undefined

Parameters:

ParameterTypeDescription
contextFlxContext-

Returns: FlxAssets | undefined

get()

ts
get<T>(id: string): T | undefined

Parameters:

ParameterTypeDescription
idstring-

Returns: T | undefined

getBitmapFont()

ts
getBitmapFont(id: string): FlxBitmapFont | undefined

Return an already-loaded Pixi bitmap font as a non-owning engine wrapper.

Parameters:

ParameterTypeDescription
idstring-

Returns: FlxBitmapFont | undefined

getGraphic()

ts
getGraphic(id: string): FlxGraphic | undefined

Parameters:

ParameterTypeDescription
idstring-

Returns: FlxGraphic | undefined

init()

ts
init(options?: FlxAssetInitOptions): Promise<void>

Parameters:

ParameterTypeDescription
optionsFlxAssetInitOptions-

Returns: Promise<void>

install()

ts
install(context: FlxContext): this

Parameters:

ParameterTypeDescription
contextFlxContext-

Returns: this

isLoaded()

ts
isLoaded(id: string): boolean

Parameters:

ParameterTypeDescription
idstring-

Returns: boolean

load()

ts
load<T>(id: string | FlxAssetDescriptor, options?: FlxAssetLoadOptions): Promise<T>

Parameters:

ParameterTypeDescription
idstring | FlxAssetDescriptor-
optionsFlxAssetLoadOptions-

Returns: Promise<T>

loadBitmapFont()

ts
loadBitmapFont(id: string | FlxAssetDescriptor, options?: FlxAssetLoadOptions): Promise<FlxBitmapFont>

Load a .fnt/.xml bitmap font and every page it references. Page textures and the Pixi font remain owned by the asset cache.

Parameters:

ParameterTypeDescription
idstring | FlxAssetDescriptor-
optionsFlxAssetLoadOptions-

Returns: Promise<FlxBitmapFont>

loadBundle()

ts
loadBundle<T = Record<string, unknown>>(name: string | string[], onProgress?: (progress: number) => void): Promise<T>

Parameters:

ParameterTypeDescription
namestring | string[]-
onProgress(progress: number) => void-

Returns: Promise<T>

loadGraphic()

ts
loadGraphic(id: string | FlxAssetDescriptor, options?: FlxAssetLoadOptions): Promise<FlxGraphic>

Parameters:

ParameterTypeDescription
idstring | FlxAssetDescriptor-
optionsFlxAssetLoadOptions-

Returns: Promise<FlxGraphic>

unload()

ts
unload(id: string | string[]): Promise<void>

Parameters:

ParameterTypeDescription
idstring | string[]-

Returns: Promise<void>

unloadBundle()

ts
unloadBundle(name: string | string[]): Promise<void>

Parameters:

ParameterTypeDescription
namestring | string[]-

Returns: Promise<void>

Released under the MIT License.