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

Sprite Class Reference

Sprite describes a single sprite, i.e. More...

#include <SpriteEngine.h>

Collaboration diagram for Sprite:

Collaboration graph

[legend]
List of all members.

Public Methods

 Sprite (DmResID bitmapID, DmResID maskID = -1, Coord hotSpotX = 0, Coord hotSpotY = 0, Boolean visible = true, AnimFrames::OptimizationMode optimizationMode = AnimFrames::optNONE)
 Create a Sprite with no animation. More...

 Sprite (AnimFrames& animFrames, Boolean visible = true)
 Create an animated sprite with the specified AnimFrames. More...

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

void show ()
 Show the sprite during subsequent draws. More...

void hide ()
 Hide the sprite during subsequent draws. More...

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

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

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

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

void draw (RectangleType *bounds = NULL) const
 Draw the sprite at its current location. More...

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


Friends

class  SpriteGroup

Detailed Description

Sprite describes a single sprite, i.e.

a movable graphical object with a transparent background.

Definition at line 149 of file SpriteEngine.h.


Constructor & Destructor Documentation

Sprite::Sprite ( DmResID bitmapID,
DmResID maskID = -1,
Coord hotSpotX = 0,
Coord hotSpotY = 0,
Boolean visible = true,
AnimFrames::OptimizationMode optimizationMode = AnimFrames::optNONE )
 

Create a Sprite with no animation.

The required AnimFrames object will be created implicitly, and will automatically be destroyed when the sprite is destroyed.

Parameters:
bitmapID   the ID of the image bitmap in the resource database.
maskID   the ID of the mask bitmap in the resource database, or -1 when no masks are desired (optimizationMode == optNO_MASK).
hotSpotX   the horizontal offset of the hotspot.
hotSpotY   the vertical offset of the hotspot.
visible   shall the sprite be visible?
optimizationMode   which optimizations shall be applied?

Definition at line 253 of file SpriteEngine.cpp.

Sprite::Sprite ( AnimFrames & animFrames,
Boolean visible = true )
 

Create an animated sprite with the specified AnimFrames.

Ownership of the AnimFrames object is NOT transferred to the Sprite. It will not automatically be destroyed when the Sprite is destroyed.

Parameters:
animFrames   a reference to an AnimFrames object
visible   shall the sprite be visible?

Definition at line 264 of file SpriteEngine.cpp.

Sprite::~Sprite ( )
 

Destroy the Sprite and deallocate all used resources.

Definition at line 275 of file SpriteEngine.cpp.


Member Function Documentation

void Sprite::draw ( RectangleType * bounds = NULL ) const
 

Draw the sprite at its current location.

Inquire the current draw window and allocate draw buffers as neccessary.

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

Definition at line 322 of file SpriteEngine.cpp.

void 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.

Definition at line 341 of file SpriteEngine.cpp.

Referenced by SpriteGroup::addSprite().

void Sprite::hide ( )
 

Hide the sprite during subsequent draws.

Definition at line 288 of file SpriteEngine.cpp.

Boolean Sprite::isVisible ( ) const
 

Will the sprite be drawn during subsequent draws?

Definition at line 303 of file SpriteEngine.cpp.

Referenced by DemoActionEngine::nextPeriod().

void Sprite::move ( Coord x,
Coord y )
 

Move the sprite (i.e.

its hotspot) to the specified coordinates.

Definition at line 315 of file SpriteEngine.cpp.

Referenced by Sprite(), DemoActionEngine::nextPeriod(), and DemoActionEngine::restoreState().

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.

Definition at line 309 of file SpriteEngine.cpp.

Referenced by Sprite(), and DemoActionEngine::nextPeriod().

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)

Definition at line 294 of file SpriteEngine.cpp.

Referenced by DemoActionEngine::nextPeriod().

void Sprite::show ( )
 

Show the sprite during subsequent draws.

Definition at line 282 of file SpriteEngine.cpp.


Friends And Related Function Documentation

class SpriteGroup [friend]
 

Definition at line 266 of file SpriteEngine.h.


The documentation for this class was generated from the following files:
Razor! Engine Developer's Guide. Copyright © by Tilo Christ. All Rights Reserved. Last updated: 17 Dec 2000