Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members

Sprite Class Reference

Collaboration diagram for Sprite:

Collaboration graph
[legend]
List of all members.

Detailed Description

Sprite describes a single sprite, i.e.

a movable graphical object with a transparent background.

Definition at line 140 of file SpriteEngine.h.

Public Member Functions

Lifecycle management
 Sprite (const AnimFrames *animFrames, Boolean visible, Boolean saveBackground) SEC_RAZOR_INIT
 Create a single new sprite.

 ~Sprite () SEC_RAZOR_INIT
 Destroy the Sprite and deallocate all used resources.

State management (visibility, position, etc.)
void show ()
 Show the sprite during subsequent draws.

void hide ()
 Hide the sprite during subsequent draws.

Boolean setVisibility (Boolean visible)
 Set the visibility of the sprite through a flag.

Boolean isVisible () const
 Will the sprite be drawn during subsequent draws?

void setFrame (UInt16 frameIndex)
 Set the displayed frame of the Sprite.

void move (Coord x, Coord y)
 Move the sprite (i.e.

Visual representation
void draw (RectangleType *bounds=NULL) SEC_RAZOR
 Draw the sprite at its current location.

void restoreBackground () const SEC_RAZOR
 Restore the saved background of the sprite.

void discardBackground () SEC_RAZOR
 Throw away the background of a sprite.

Boolean getBounds (RectangleType *bounds) const
 Get the screen space filled by the sprite.


Friends

class SpriteGroup


Constructor & Destructor Documentation

Sprite::Sprite const AnimFrames   animFrames,
Boolean    visible,
Boolean    saveBackground
 

Create a single new sprite.


Look at SpriteGroup if you wish to create a multitude of sprites.

Parameters:
animFrames the animation frames for this sprite
visible shall the sprite be visible?
saveBackground shall the sprite be able to save and restore its background?

Sprite::~Sprite  
 

Destroy the Sprite and deallocate all used resources.


Member Function Documentation

void Sprite::show  
 

Show the sprite during subsequent draws.

void Sprite::hide  
 

Hide the sprite during subsequent draws.

Boolean Sprite::setVisibility Boolean    visible
 

Set the visibility of the sprite through a flag.

Parameters:
visible shall the sprite be visible (true = shown / false = hidden)

Boolean Sprite::isVisible   const
 

Will the sprite be drawn during subsequent draws?

void Sprite::setFrame UInt16    frameIndex
 

Set the displayed frame of the Sprite.

Parameters:
frameIndex the index of the displayed frame. Must be between 0..numFrames-1 of the associated AnimFrames.

void Sprite::move Coord    x,
Coord    y
 

Move the sprite (i.e.

its hotspot) to the specified coordinates.

void Sprite::draw RectangleType *    bounds = NULL
 

Draw the sprite at its current location.

If the sprite has been set to save its background, the background will be saved before the sprite will be drawn.

Parameters:
bounds a pointer to a rectangle which will be filled with the screen space filled by the sprite, or NULL.

void Sprite::restoreBackground   const
 

Restore the saved background of the sprite.

This operation will not do anything if the sprite has been either not drawn, or the background has been discarded since the last draw operation.

void Sprite::discardBackground  
 

Throw away the background of a sprite.

Boolean Sprite::getBounds RectangleType *    bounds const
 

Get the screen space filled by the sprite.

Parameters:
bounds a pointer to a rectangle which will be filled with the screen space filled by the sprite.
Returns:
True, if the Sprite is completely off the screen, False if it is at least partially on the screen


Friends And Related Function Documentation

friend class SpriteGroup [friend]
 

Definition at line 286 of file SpriteEngine.h.


The documentation for this class was generated from the following file:
Razor! Engine Developer's Guide. Copyright © by Tilo Christ. All Rights Reserved. Last updated: 31 May 2003