Skip to main content

Gif

The [[Texture]] object allows games built in Excalibur to load image resources. [[Texture]] is an [[Loadable]] which means it can be passed to a [[Loader]] to pre-load before starting a level or game.

Implements

Index

Constructors

constructor

  • new Gif(path: string, color?: Color, bustCache?: boolean): Gif
  • Parameters

    • path: string

      Path to the image resource

    • color: Color = Color.Magenta

      Optionally set the color to treat as transparent the gif, by default [[Color.Magenta]]

    • bustCache: boolean = false

      Optionally load texture with cache busting

    Returns Gif

Properties

publiccolor

color: Color = Color.Magenta

Optionally set the color to treat as transparent the gif, by default [[Color.Magenta]]

publicdata

data: ImageSource[]

Data associated with a loadable

publicheight

height: number

The height of the texture in pixels

publicpath

path: string

Path to the image resource

publicwidth

width: number

The width of the texture in pixels

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

publicreadCheckBytes

  • get readCheckBytes(): number[]
  • Returns number[]

Methods

publicisLoaded

  • isLoaded(): boolean
  • Returns true if the loadable is loaded


    Returns boolean

publicload

  • Begins loading the texture and returns a promise to be resolved on completion


    Returns Promise<ImageSource[]>

publictoAnimation

  • toAnimation(durationPerFrameMs: number): Animation
  • Transform the GIF into an animation with duration per frame


    Parameters

    • durationPerFrameMs: number

    Returns Animation

publictoSprite

  • Return a frame of the gif as a sprite by id


    Parameters

    • id: number = 0

    Returns Sprite

publictoSpriteSheet