Skip to main content

Resource <T>

The [[Resource]] type allows games built in Excalibur to load generic resources. For any type of remote resource it is recommended to use [[Resource]] for preloading.

Implements

Index

Constructors

constructor

  • new Resource<T>(path: string, responseType: | text | arraybuffer | blob | document | json, bustCache?: boolean): Resource<T>
  • Type parameters

    • T

    Parameters

    • path: string

      Path to the remote resource

    • responseType: | text | arraybuffer | blob | document | json

      The type to expect as a response: "" | "arraybuffer" | "blob" | "document" | "json" | "text";

    • bustCache: boolean = false

      Whether or not to cache-bust requests

    Returns Resource<T>

Properties

publicbustCache

bustCache: boolean = false

Whether or not to cache-bust requests

publicdata

data: T = null

Data associated with a loadable

publicevents

events: EventEmitter<any> = ...

publiclogger

logger: Logger = ...

publicpath

path: string

Path to the remote resource

publicresponseType

responseType: | text | arraybuffer | blob | document | json

The type to expect as a response: "" | "arraybuffer" | "blob" | "document" | "json" | "text";

Methods

publicisLoaded

  • isLoaded(): boolean
  • Returns true if the Resource is completely loaded and is ready to be drawn.


    Returns boolean

publicload

  • load(): Promise<T>
  • Begin loading the resource and returns a promise to be resolved on completion


    Returns Promise<T>