Documentation generator: JsDoc Toolkit 2.4.0
Template: Codeview 1.2
Generated on: 2014-7-16 16:20

Class jaws.Animation

Manages an animation with a given list of frames. "Field Summary" contains options for the Animation()-constructor.

Class Summary
Constructor Attributes Constructor Name and Description
 
jaws.Animation(options)
Field Summary
Field Attributes Field Name and Description
 
Rewind the animation frame by frame when end is reached
 
-1 for backwards animation.
 
How long should each frame be displayed
 
Containing width/height, eg.
 
Images/canvaselements
 
Start on this frame
 
Restart animation when end is reached
 
When cutting out frames from a sprite sheet, start at this frame
 
Function to call when animation ends.
 
How to cut out frames frmo sprite sheet, possible values are "down" or "right"
 
Name specific frames-intervals for easy access later, i.e.

Method Summary

Method Attributes Method Name and Description
 
returns true if animation is at the very first frame
 
returns true if animation is at the very last frame
 
returns the current frame
 
next()
Moves animation forward by calling update() and then return the current frame
 
slice(start, stop)
works like Array.slice but returns a new Animation-object with a subset of the frames
 
subset(subset)
Return a special animationsubset created with "subset"-parameter when initializing
 
Debugstring for Animation()-constructor
 
Propells the animation forward by counting milliseconds and changing this.index accordingly Supports looping and bouncing animations

Class Detail

jaws.Animation(options)
// in setup()
anim = new jaws.Animation({sprite_sheet: "droid_11x15.png", frame_size: [11,15], frame_duration: 100})
player = new jaws.Sprite({y:300, anchor: "center_bottom"})

// in update()
player.setImage( anim.next() )

// in draw()
player.draw()
Parameters:
options

Field Detail

{bool} bounce
Rewind the animation frame by frame when end is reached
{int} frame_direction
-1 for backwards animation. 1 is default
{milliseconds} frame_duration
How long should each frame be displayed
{array} frame_size
Containing width/height, eg. [32, 32]
{array} frames
Images/canvaselements
{int} index
Start on this frame
{bool} loop
Restart animation when end is reached
{int} offset
When cutting out frames from a sprite sheet, start at this frame
{function} on_end
Function to call when animation ends. triggers only on non-looping, non-bouncing animations
{string} orientation
How to cut out frames frmo sprite sheet, possible values are "down" or "right"
{object} subsets
Name specific frames-intervals for easy access later, i.e. {move: [2,4], fire: [4,6]}. Access with animation.subset[name]

Method Detail

  • atFirstFrame()
    returns true if animation is at the very first frame
  • atLastFrame()
    returns true if animation is at the very last frame
  • currentFrame()
    returns the current frame
  • Moves animation forward by calling update() and then return the current frame
  • slice(start, stop)
    works like Array.slice but returns a new Animation-object with a subset of the frames
    Parameters:
    start
    stop
  • subset(subset)
    Return a special animationsubset created with "subset"-parameter when initializing
    Parameters:
    subset
  • toString()
    Debugstring for Animation()-constructor
    var anim = new Animation(...)
    console.log(anim.toString())
  • update()
    Propells the animation forward by counting milliseconds and changing this.index accordingly Supports looping and bouncing animations