Options
All
  • Public
  • Public/Protected
  • All
Menu

Sprite sheets are a useful mechanism for slicing up image resources into separate sprites or for generating in game animations. Sprites are organized in row major order in the SpriteSheet.

Hierarchy

Index

Constructors

constructor

Properties

columns

columns: number = 0

image

image: Texture = null

rows

rows: number = 0

spHeight

spHeight: number = 0

spWidth

spWidth: number = 0

spacing

spacing: number = 0

sprites

sprites: Sprite[] = []

Methods

getAnimationBetween

  • getAnimationBetween(engine: Engine, beginIndex: number, endIndex: number, speed: number): Animation
  • Create an animation from the this SpriteSheet by specifying the range of images with the beginning (inclusive) and ending (exclusive) index For example getAnimationBetween(engine, 0, 5, 200) returns an animation with 5 frames.

    Parameters

    • engine: Engine

      Reference to the current game Engine

    • beginIndex: number

      The index to start taking frames (inclusive)

    • endIndex: number

      The index to stop taking frames (exclusive)

    • speed: number

      The number in milliseconds to display each frame in the animation

    Returns Animation

getAnimationByCoords

  • Get an animation with bespoke sprite coordinates. This is useful if the SpriteSheet is packed and not a uniform width or height. The resulting Animation will have the height and width of the largest dimension (width, height) from among the sprite coordinates

    Parameters

    Returns Animation

getAnimationByIndices

  • getAnimationByIndices(engine: Engine, indices: number[], speed: number): Animation
  • Create an animation from the this SpriteSheet by listing out the sprite indices. Sprites are organized in row major order in the SpriteSheet.

    Parameters

    • engine: Engine

      Reference to the current game Engine

    • indices: number[]

      An array of sprite indices to use in the animation

    • speed: number

      The number in milliseconds to display each frame in the animation

    Returns Animation

getAnimationForAll

  • Treat the entire SpriteSheet as one animation, organizing the frames in row major order.

    Parameters

    • engine: Engine

      Reference to the current game Engine

    • speed: number

      The number in milliseconds to display each frame the animation

    Returns Animation

getSprite

  • getSprite(index: number): Sprite
  • Retrieve a specific sprite from the SpriteSheet by its index. Sprites are organized in row major order in the SpriteSheet.

    Parameters

    • index: number

      The index of the sprite

    Returns Sprite