Sprite


Inheritance Sprite View Module hilo/view/Sprite Requires hilo/core/Hilo, hilo/core/Class, hilo/view/View, hilo/view/Drawable Source Sprite.js
Sprite animation class.


Properties

Show Inherited Properties
Property Defined
currentFrame:number
Current showing frame index, range from 0, readoly!
Sprite
interval:number
Interval between sprite animation frames.
Sprite
loop:boolean
Is sprite play in loop, default value is false.
Sprite
onEnterFrame:Function
Callback function on when sprite enter a new frame.
Sprite
paused:boolean
Is sprite paused, default value is false.
Sprite
timeBased:boolean
Is sprite animate base on time, default value is false (base on frame).
Sprite

Methods

Show Inherited Methods
Method Defined
Sprite(properties)
Constructor
Sprite
addFrame(frame:Object, startIndex:Int):Sprite
Add frame into sprite.
Sprite
getFrame(indexOrName:Object):Object
Get the frame of given parameter from sprite.
Sprite
getFrameIndex(frameValue:Object):Object
Get frame index from sprite.
Sprite
getNumFrames():Uint
Return the total amount of sprite animation frames.
Sprite
goto(indexOrName:Object, pause:Boolean):Sprite
Jump to an assigned frame.
Sprite
play():Sprite
Play sprite.
Sprite
setFrame(frame:Object, index:Int):Sprite
Set the frame on the given index.
Sprite
setFrameCallback(frame:Int|String, callback:Function):Sprite
Set a callback on an assigned frame.
Sprite
stop():Sprite
Pause playing sprite.
Sprite

Property Detail

currentFrame:number
Current showing frame index, range from 0, readoly!
interval:number
Interval between sprite animation frames. If timeBased is true, measured in ms, otherwise, measured in frames.
loop:boolean
Is sprite play in loop, default value is false.
onEnterFrame:Function
Callback function on when sprite enter a new frame. default value is null. Note: this function is obsolete, use addFrameCallback funciton instead.
paused:boolean
Is sprite paused, default value is false.
timeBased:boolean
Is sprite animate base on time, default value is false (base on frame).

Constructor

Sprite(properties)
parameters
properties — Properties parameters for creating object, include all writable properties of this class, also include:
  • frames - Sprite animation frames data object.

Method Detail

addFrame(frame:Object, startIndex:Int):Sprite
Add frame into sprite.
parameters
frame:Object — Frames to add into.
startIndex:Int — The index to start adding frame, if is not given, add at the end of sprite.
return
Sprite — Sprite itself.
getFrame(indexOrName:Object):Object
Get the frame of given parameter from sprite.
parameters
indexOrName:Object — The index or name of the frame.
return
Object — The sprite object.
getFrameIndex(frameValue:Object):Object
Get frame index from sprite.
parameters
frameValue:Object — Index or name of the frame.
return
Object — Sprite frame object.
getNumFrames():Uint
Return the total amount of sprite animation frames.
return
Uint — The total amount of frames.
goto(indexOrName:Object, pause:Boolean):Sprite
Jump to an assigned frame.
parameters
indexOrName:Object — Index or name of an frame to jump to.
pause:Boolean — Does pause after jumping to the new index.
return
Sprite — The Sprite object.
play():Sprite
Play sprite.
return
Sprite — The Sprite object.
setFrame(frame:Object, index:Int):Sprite
Set the frame on the given index.
parameters
frame:Object — The frame data to set on that index.
index:Int — Index of the frame to set.
return
Sprite — Sprite itself.
setFrameCallback(frame:Int|String, callback:Function):Sprite
Set a callback on an assigned frame. Every time assigned frame is played, invoke the callback function. If callback is empty, callback function will be removed.
parameters
frame:Int|String — Index or name of the assigned frame.
callback:Function — Callback function.
return
Sprite — The Sprite object.
stop():Sprite
Pause playing sprite.
return
Sprite — The Sprite object.