Skip to main content

ImageSource

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

Implements

Index

Constructors

constructor

  • The path to the image, can also be a data url like 'data:image/'


    Parameters

    • path: string

      {string} Path to the image resource relative from the HTML document hosting the game, or absolute

    • optionaloptions: ImageSourceOptions

    Returns ImageSource

Properties

publicdata

data: HTMLImageElement = ...

Access to the underlying html image element

publicfiltering

filtering: ImageFiltering

publicreadonlypath

path: string

publicready

ready: Promise<HTMLImageElement> = ...

Promise the resolves when the image is loaded and ready for use, does not initiate loading

publicwrapping

Accessors

publicbustCache

  • get bustCache(): boolean
  • set bustCache(val: boolean): void
  • Should excalibur add a cache busting querystring? By default false. Must be set before loading


    Returns boolean

  • Parameters

    • val: boolean

    Returns void

publicheight

  • get height(): number
  • The original height of the source image in pixels


    Returns number

publicimage

  • get image(): HTMLImageElement
  • Returns HTMLImageElement

publicwidth

  • get width(): number
  • The original size of the source image in pixels


    Returns number

Methods

publicisLoaded

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


    Returns boolean

load

  • load(): Promise<HTMLImageElement>
  • Begins loading the image and returns a promise that resolves when the image is loaded


    Returns Promise<HTMLImageElement>

publictoSprite

  • Build a sprite from this ImageSource


    Returns Sprite

unload

  • unload(): void
  • Unload images from memory


    Returns void

staticfromHtmlImageElement