Skip to content

v1.2.5 add Action.animate(…)

Latest
Compare
Choose a tag to compare
@reececomo reececomo released this 31 Jan 10:49

v1.2.5

Added Action.animate(…):

  • Animate a Sprite using textures or a spritesheet.
  • Features:
    • Full timing/actions control
    • Reversible
    • Auto-resize (default: off)
    • Auto-restore (default: on)

Tip

Action.animate(…) is the stateless analog of creating a PIXI.AnimatedSprite.

Example usage:

// textures
const walkAnimation = Action.animate([
  walkTexture1,
  walkTexture2,
  /*…*/
])

// spritesheet
const runSpritesheet: Spritesheet = Assets.get("runAnimation")
const runAnimation = Action.animate(runSpritesheet, 1/24) // @24 FPS

mySprite.run(Action.repeatForever(
  Action.sequence([walkAnimation, runAnimation])
))

Args

Textures – animate( textures, timePerFrame, resize, restore )

Animates changes to a sprite’s texture.

Action.animate(
  textures: Textures[],
  timePerFrame: number      = 1/60,
  resize: boolean           = false,
  restore: boolean          = true
)

Spritesheet – animate( spritesheet, timePerFrame, resize, restore, sortByKey )

Play a spritesheet as an animation sheet. By default textures are played in sorted order.

Action.animate(
  spritesheet: Spritesheet,
  timePerFrame: number      = 1/60,
  resize: boolean           = false,
  restore: boolean          = true,
  sortByKey: boolean        = true
)