Polycode
Polycode::ScreenSprite Class Reference

Animated 2D image sprite. More...

Inherits Polycode::ScreenShape.

List of all members.

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.

Detailed Description

Animated 2D image sprite.

This screen entity can load spritesheet images and play back animations.


Constructor & Destructor Documentation

ScreenSprite::ScreenSprite ( const String fileName,
Number  spriteWidth,
Number  spriteHeight 
)

Create a sprite from a spritesheet image of specified size.

Parameters:
fileNameImage file to load spritesheet from.
spriteWidthPixel width of each sprite cell.
spriteWidthPixel height of each sprite cell.

Member Function Documentation

void ScreenSprite::addAnimation ( const String name,
const String frames,
Number  speed 
)

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.

Parameters:
nameName of the new animation.
framesA 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.

Parameters:
nameName of the animation to play.
startFrameStarting frame for playback.
onceIf 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.