Animated 2D image sprite. More...
Inherits Polycode::ScreenShape.
Public Member Functions | |
ScreenSprite (const String &fileName, Number spriteWidth, Number spriteHeight) | |
Create a sprite from a spritesheet image of specified size. | |
void | addAnimation (const String &name, const String &frames, Number speed) |
Adds a new animation to the sprite. | |
void | playAnimation (const String &name, int startFrame, bool once) |
Play back a previously created animation by name. | |
void | Update () |
Main update method. |
Animated 2D image sprite.
This screen entity can load spritesheet images and play back animations.
ScreenSprite::ScreenSprite | ( | const String & | fileName, | |
Number | spriteWidth, | |||
Number | spriteHeight | |||
) |
Create a sprite from a spritesheet image of specified size.
fileName | Image file to load spritesheet from. | |
spriteWidth | Pixel width of each sprite cell. | |
spriteWidth | Pixel height of each sprite cell. |
Adds a new animation to the sprite.
Animations are added by specifying a list of frame indexes and then can be played back by the specified name.
name | Name of the new animation. | |
frames | A comma separated list of frames indexes to include in the animation. Speed at which to play back the animation. |
void ScreenSprite::playAnimation | ( | const String & | name, | |
int | startFrame, | |||
bool | once | |||
) |
Play back a previously created animation by name.
name | Name of the animation to play. | |
startFrame | Starting frame for playback. | |
once | If true, only plays once, otherwise loops. |
void ScreenSprite::Update | ( | ) | [virtual] |
Main update method.
Override this to do your updates before the render cycle.
Reimplemented from Polycode::Entity.