API Document Index



Class me.AnimationSheet


Extends me.SpriteObject.

Defined in: <build/melonJS-0.9.3.js>.

Class Summary
Constructor Attributes Constructor Name and Description
 
me.AnimationSheet(x, y, Image, spritewidth, spriteheight)
an object to manage animation
Field Summary
Field Attributes Field Name and Description
 
animation cycling speed
default value : me.sys.fps / 10;
Fields borrowed from class me.SpriteObject:
autodestroy, visible
Fields borrowed from class me.Rect:
bottom, height, left, pos, right, top, width
Method Summary
Method Attributes Method Name and Description
 
addAnimation(name, index)
add an animation
the index list must follow the logic as per the following example :
 
return true if the specified animation is the current one.
 
force the current animation frame index.
 
setCurrentAnimation(name, onComplete)
set the current animation
 
update the animation
this is automatically called by the game manager me.game
Methods borrowed from class me.SpriteObject:
draw, flicker, flipX, flipY, isFlickering, onDestroyEvent, resize, setTransparency
Methods borrowed from class me.Rect:
contains, containsPoint, getRect, overlaps, set, union, within
Class Detail
me.AnimationSheet(x, y, Image, spritewidth, spriteheight)
an object to manage animation
Parameters:
{int} x
the x coordinates of the sprite object
{int} y
the y coordinates of the sprite object
{me.loader#getImage} Image
reference of the animation sheet
{int} spritewidth
width of a single sprite within the spritesheet
{int} spriteheight Optional
height of a single sprite within the spritesheet (value will be set to the image height if not specified)
Field Detail
{Number} animationspeed
animation cycling speed
default value : me.sys.fps / 10;
Method Detail
addAnimation(name, index)
add an animation
the index list must follow the logic as per the following example :
// walking animatin
this.addAnimation ("walk", [0,1,2,3,4,5]);
// eating animatin
this.addAnimation ("eat", [6,6]);
// rolling animatin
this.addAnimation ("roll", [7,8,9,10]);
Parameters:
{String} name
animation id
{Int[]} index
list of sprite index defining the animaton

isCurrentAnimation(name)
return true if the specified animation is the current one.
if (!this.isCurrentAnimation("walk"))
{
   // do something horny...
}
Parameters:
{String} name
animation id

setAnimationFrame(index)
force the current animation frame index.
//reset the current animation to the first frame
this.setAnimationFrame();
Parameters:
{int} index Optional, Default: 0

setCurrentAnimation(name, onComplete)
set the current animation
// set "walk" animation
this.setCurrentAnimation("walk");
// set "eat" animation, and switch to "walk" when complete
this.setCurrentAnimation("eat", "walk");
// set "die" animation, and remove the object when finished
this.setCurrentAnimation("die", function(){me.game.remove(this)});
Parameters:
{String} name
animation id
{Object} onComplete Optional
animation id to switch to when complete, or callback

update()
update the animation
this is automatically called by the game manager me.game

Documentation generated by JsDoc Toolkit 2.4.0 on Tue May 01 2012 12:00:48 GMT+0800 (CST)