Reference Source Test
public class | source

Animation

Control animations for a sprite

Constructor Summary

Public Constructor
public

constructor(name: String, length: Number, row: Number, width: Number, height: Number)

Default constructor

Member Summary

Public Members
public

An internal counter for the callback

public

The current frame in the animation

public

End of counter calback function

public

Height of 1 frame in the animation in pixels

public

The last time the animation was updated

public

Number of rames in the animation

public

Sprite sheet

public

Row of the animation in the sprite sheet

public

The speed of the animation in miliseconds

public

Width of 1 frame in the animation in pixels

Method Summary

Public Methods
public

Figure out whether or not this animation is ready to animate again

public

reset()

Reset the animation back to the beginning

public

setCount(count: Number, onEndCount: Function)

Set the counter for the callback, used for attack sequences

public

setRow(row: Number)

Set the row the animation is in

public

setSpeed(speed: Number)

Set the speed of the animation

public

tick(): Void

Grab the next frame in the animation

public

Update the animation over time by changing to the next frame

Public Constructors

public constructor(name: String, length: Number, row: Number, width: Number, height: Number) source

Default constructor

Params:

NameTypeAttributeDescription
name String

sprite sheet name

length Number

frame length of the animation

row Number

row in the sprite sheet

width Number

width of 1 frame in the animation

height Number

height of 1 frame in the animation

Public Members

public count: Number source

An internal counter for the callback

public currentFrame: Number source

The current frame in the animation

public endCountCallback: Function source

End of counter calback function

public height: Number source

Height of 1 frame in the animation in pixels

public lastTime: Number source

The last time the animation was updated

public length: Number source

Number of rames in the animation

public name: String source

Sprite sheet

public row: Number source

Row of the animation in the sprite sheet

public speed: Number source

The speed of the animation in miliseconds

public width: Number source

Width of 1 frame in the animation in pixels

Public Methods

public readyToAnimate(time: Number): Boolean source

Figure out whether or not this animation is ready to animate again

Params:

NameTypeAttributeDescription
time Number

time in miliseconds

Return:

Boolean

returns true if difference between lasttime > speed

public reset() source

Reset the animation back to the beginning

public setCount(count: Number, onEndCount: Function) source

Set the counter for the callback, used for attack sequences

Params:

NameTypeAttributeDescription
count Number

update the animation callback counter

onEndCount Function

set the callback function when the count ends

public setRow(row: Number) source

Set the row the animation is in

Params:

NameTypeAttributeDescription
row Number

row in the sprite sheet

public setSpeed(speed: Number) source

Set the speed of the animation

Params:

NameTypeAttributeDescription
speed Number

in miliseconds

public tick(): Void source

Grab the next frame in the animation

Return:

Void

public update(time: Number): Boolean source

Update the animation over time by changing to the next frame

Params:

NameTypeAttributeDescription
time Number

a duration of time

Return:

Boolean

returns false if not ready to animate again