Options
All
  • Public
  • Public/Protected
  • All
Menu

Handles animations for an object.

Example

// In the implementation of a class
this.anims = new Animations({ x: 0, y: 0, custom: 'properties' })
// Create 'idle' animation with two frames that change every half second.
this.anims.add('idle', [{ x: 0, y: 0 }, { x: 1, y: 0}], .5)

// In the update of the same class
this.anims.play('idle')

Hierarchy

  • Animations

Index

Constructors

Methods

Constructors

constructor

Methods

add

  • add(name: string, frames: Point[], speed: number): Animation
  • Add a new animation by name, using specified frames and timing.

    Overrides existing animation if the same name is used.

    Parameters

    • name: string

      The animation name.

    • frames: Point[]

      Sprite frames used in the animation.

    • speed: number

      How quickly to change between frames (based upon delta time).

    Returns Animation

play

  • play(anim: string): void
  • Set the named animation as the current animation and reset it.

    Parameters

    • anim: string

      The name of the animation to play.

    Returns void

stop

  • stop(): void

update

  • update(dt: number): void
  • Update the current animation if one is set.

    Called by [TileSprite.update()]{@link TileSprite#update}.

    Parameters

    • dt: number

      Delta time since last update.

    Returns void