# Two.Sprite
Extends: Two.Rectangle
A convenient package to display still or animated images through a tiled image source. For more information on the principals of animated imagery through tiling see Texture Atlas (opens new window) on Wikipedia.
# Constructor
Argument | Description |
---|---|
path | The URL path or Two.Texture to be used as the bitmap data displayed on the sprite. |
ox | The initial x position of the Two.Sprite. |
oy | The initial y position of the Two.Sprite. |
cols | The number of columns the sprite contains. |
rows | The number of rows the sprite contains. |
frameRate | The frame rate at which the partitions of the image should playback at. |
# frameRate
Two.Sprite.frameRate
The number of frames to animate against per second. Defaults to 0
for non-animated sprites.
# play
Two.Sprite.play
Argument | Description |
---|---|
firstFrame | The index of the frame to start the animation with. |
lastFrame | The index of the frame to end the animation with. Defaults to the last item in the Two.Sprite.textures. |
onLastFrame | Optional callback function to be triggered after playing the last frame. This fires multiple times when the sprite is looped. |
Initiate animation playback of a Two.Sprite.
# stop
Two.Sprite.stop
Halt animation playback of a Two.Sprite and set the current frame back to the first frame.
# clone
Two.Sprite.clone
Returns: Two.Sprite
Argument | Description |
---|---|
parent | The parent group or scene to add the clone to. |
Create a new instance of Two.Sprite with the same properties of the current sprite.
# toObject
Two.Sprite.toObject
Returns: Object
Return a JSON compatible plain object that represents the path.