Skip to content

Animatable

Isuru Kusumal Rajapakse edited this page Jun 18, 2017 · 1 revision

new Animatable()

  • Represents a component that defines a animatable behaviors like animate, play etc.
Returns
  • Void

Animatable.state()

returns the current state the sprite is in

Returns
  • state current state

Animatable.goto(id)

set the current state of the animation

Parameters
Name Type Description
id string - unique name of the animation to go to  
Returns
  • Sprite itself

Animatable.play(fpt)

plays the animation associated in the state (if any)

Parameters
Name Type Description
fpt string - sets the speed of playback [<0=slowmotion, 0=stopped, 1=normal, 1>=fastmotion]  
Returns
  • Sprite itself

Animatable.stop()

stops the animation associated in the state (if any)

Returns
  • Sprite itself

Animatable.rewind([to=0])

rewinds the animation associated in the state (if any) rewinds to the start by default.

Parameters
Name Type Description
to=0 in - sets the frame to rewind to Optional
Returns
  • Sprite itself

Animatable.source(url)

sets a static layered image resources for the desired sprite important ! - the last last layer renders on top important ! - the first layer will be used as the collision mask by defult

Parameters
Name Type Description
url Array.<string> - location of the images layer by layer.  
Returns
  • Sprite itself

Animatable.animate(name, urls, nr, nc, sf, repeat)

sets animated spritesheet resources for the desired sprite important ! - the last last layer renders on top important ! - the first layer will be used as the collision mask by defult

Parameters
Name Type Description
name string - unique name to identify each animation state  
urls Array.<string> - location(s) of the spritesheet images layer by layer.  
nr int - number of rows in the spritesheet  
nc int - number of colomns in the spritesheet  
sf string - starting frame of the said state  
repeat int - times should the animation repeat [-1: repeat forever, 0:don't animate , 1:repeat once ...]  
Returns
  • Sprite itself

Animatable.process()

defines how the component state change on one update

Returns
  • Void

Clone this wiki locally