Skip to main content

DefaultLoader

An interface describing loadable resources in Excalibur. Built-in loadable resources include [[Texture]], [[Sound]], and a generic [[Resource]].

Hierarchy

Implements

Index

Constructors

constructor

Properties

publiccanvas

canvas: Canvas = ...

publicdata

data: Loadable<any>[]

Data associated with a loadable

publicengine

engine: Engine<any>

publicevents

events: EventEmitter<LoaderEvents> = ...

Accessors

publicprogress

  • get progress(): number
  • Returns the progress of the loader as a number between [0, 1] inclusive.


    Returns number

publicresources

  • get resources(): readonly Loadable<any>[]

Methods

publicaddResource

  • addResource(loadable: Loadable<any>): void
  • Add a resource to the loader to load


    Parameters

    Returns void

publicaddResources

  • addResources(loadables: Loadable<any>[]): void
  • Add a list of resources to the loader to load


    Parameters

    • loadables: Loadable<any>[]

      The list of resources to load

    Returns void

publicareResourcesLoaded

  • areResourcesLoaded(): Promise<void>
  • Returns Promise<void>

publicemit

  • emit<TEventName>(eventName: TEventName, event: LoaderEvents[TEventName]): void
  • emit(eventName: string, event?: any): void

publicisLoaded

  • isLoaded(): boolean
  • Returns true if the loader has completely loaded all resources


    Returns boolean

publicload

  • Not meant to be overridden

    Begin loading all of the supplied resources, returning a promise that resolves when loading of all is complete AND the user has interacted with the loading screen


    Returns Promise<Loadable<any>[]>

publicmarkResourceComplete

  • markResourceComplete(): void
  • Returns void

publicoff

  • off<TEventName>(eventName: TEventName, handler: Handler<LoaderEvents[TEventName]>): void
  • off(eventName: string, handler: Handler<unknown>): void
  • off(eventName: string): void

publicon

publiconAfterLoad

  • onAfterLoad(): Promise<void>
  • Overridable lifecycle method, called after loading has completed


    Returns Promise<void>

publiconBeforeLoad

  • onBeforeLoad(): Promise<void>
  • Overridable lifecycle method, called directly before loading starts


    Returns Promise<void>

onDraw

  • onDraw(ctx: CanvasRenderingContext2D): void
  • Optionally override the onDraw


    Parameters

    • ctx: CanvasRenderingContext2D

    Returns void

publiconInitialize

  • onInitialize(engine: Engine<any>): void
  • Called by the engine before loading


    Parameters

    Returns void

onUpdate

  • onUpdate(engine: Engine<any>, elapsedMilliseconds: number): void
  • Optionally override the onUpdate


    Parameters

    • engine: Engine<any>
    • elapsedMilliseconds: number

    Returns void

publiconUserAction

  • onUserAction(): Promise<void>
  • Return a promise that resolves when the user interacts with the loading screen in some way, usually a click.

    It's important to implement this in order to unlock the audio context in the browser. Browsers automatically prevent audio from playing until the user performs an action.


    Returns Promise<void>

publiconce