CanvasAnimation

CanvasAnimation

A helper class providing utility methods for PIXI Canvas animation

Constructor

new CanvasAnimation()

Members

animations :Object.<string, {fn: function(), context: PIXI.Container, resolve: function()}>

Track an object of active animations by name, context, and function This allows a currently playing animation to be referenced and terminated

Type:
  • Object.<string, {fn: function(), context: PIXI.Container, resolve: function()}>

Methods

(async, static) animateLinear(attributes, options) → {Promise}

Apply a linear animation from the current value of some attribute to a new value Resolve a Promise once the animation has concluded and the attributes have reached their new target

Example
let animation = [
  {
    parent: token,
    attribute: x,
    to: 1000
  },
  {
    parent: token,
    attribute: y,
    to: 2000
  }
];
CanvasAnimation.animateLinear(attributes, {duration:500, ontick: console.log("ticking")});
Parameters:
Name Type Description
attributes Array.<object>

An array of attributes to animate. Structure of the Array is shown in the example

options object

Additional options which customize the animation

Properties
Name Type Attributes Default Description
context Container <optional>

An animation context to use which defines scope

name string

Provide a unique animation name which may be referenced later

duration number <optional>
1000

The duration in milliseconds over which the animation should occur

ontick function <optional>

A function which defines additional behaviors to apply every animation frame

Returns:

A Promise which resolves once the linear animation has concluded

Type
Promise

(static) terminateAnimation(name)

If an animation using a certain name already exists, terminate it

Parameters:
Name Type Description
name string

The animation name to terminate