wsp::Sprite Class Reference

A basic drawable object with animation support. More...

#include <sprite.h>

Inheritance diagram for wsp::Sprite:

wsp::Layer

List of all members.

Public Member Functions

 Sprite ()
 Constructor.
virtual ~Sprite ()
 Destructor.
void SetImage (Image *image, u32 frameWidth=0, u32 frameHeight=0)
const ImageGetImage () const
void SetTransform (TRANSFORM transform)
TRANSFORM GetTransform () const
void SetRotation (f32 rotation)
f32 GetRotation () const
void SetZoom (f32 zoom)
f32 GetZoom () const
void SetTransparency (u8 alpha)
u8 GetTransparency () const
void DefineCollisionRectangle (f32 x, f32 y, f32 width, f32 height)
const RectangleGetCollisionRectangle () const
bool CollidesWith (const Rectangle *rect, f32 x=0, f32 y=0) const
bool CollidesWith (const Sprite *sprite) const
bool CollidesWith (const TiledLayer *tiledlayer) const
u32 GetFrame () const
u32 GetFrameSequenceLength () const
u32 GetRawFrameCount () const
 Gets how many frames there are at all.
void SetFrame (u32 sequenceIndex)
void NextFrame ()
 Sets the current frame to the next frame in the sequence. Goes back to the first member if no frames left in the sequence.
void PrevFrame ()
 Sets the current frame to the previous frame in the sequence. Goes to the last member if the current frame is 0.
void SetFrameSequence (u32 *sequence, u32 length)
void Draw (f32 offsetX=0, f32 offsetY=0) const
 Draws the Sprite.


Detailed Description

A basic drawable object with animation support.

Member Function Documentation

void wsp::Sprite::SetImage ( Image image,
u32  frameWidth = 0,
u32  frameHeight = 0 
)

Assigns this sprite to an image. If there is already an image with the same size, no data gets changed.

Parameters:
image The image for this sprite.
frameWidth The width of the frame. Should be a multiple of image->GetWidth() or 0 if it should get the same width as the image.
frameHeight The height of the frame. Should be a multiple of image->GetHeight() or 0 if it should get the same height as the image.

const Image* wsp::Sprite::GetImage (  )  const

Gets the assigned image.

Returns:
A pointer to the image. NULL if no image was assigned.

void wsp::Sprite::SetTransform ( TRANSFORM  transform  ) 

Changes the transformation of the texture.

Parameters:
transform The new transformation for the texture.

TRANSFORM wsp::Sprite::GetTransform (  )  const

Gets the texture transformation.

Returns:
The transformation of the texture.

void wsp::Sprite::SetRotation ( f32  rotation  ) 

Sets the rotation angle of the sprite.

Parameters:
rotation The new angle of the sprite.

f32 wsp::Sprite::GetRotation (  )  const

Gets the rotation angle of the sprite.

Returns:
The current angle of the sprite.

void wsp::Sprite::SetZoom ( f32  zoom  ) 

Sets the zooming of the sprite.

Parameters:
zoom The new zoom of the sprite. 1 is normal size, cannot be smaller than 0.

f32 wsp::Sprite::GetZoom (  )  const

Gets the zooming of the sprite.

Returns:
The current zoom of the sprite. 1 is normal size.

void wsp::Sprite::SetTransparency ( u8  alpha  ) 

Sets the transparency of the sprite.

Parameters:
alpha Sets the transparency. Has a range from 0x00 (invisible) to 0xFF (fully visible)

u8 wsp::Sprite::GetTransparency (  )  const

Gets the transparency of the sprite.

Returns:
The current transparency of the sprite. Has a range from 0x00 (invisible) to 0xFF (fully visible)

void wsp::Sprite::DefineCollisionRectangle ( f32  x,
f32  y,
f32  width,
f32  height 
)

Defines a collision rectangle. On startup it's the same as Image width and height.

Parameters:
x Offset from the upper left corners position of the sprite.
y Offset from the upper left corners position of the sprite.
width The width of the collision rectangle.
height The height of the collision rectangle.

const Rectangle* wsp::Sprite::GetCollisionRectangle (  )  const

Gets the current collision rectangle.

Returns:
A pointer to the rectangle.

bool wsp::Sprite::CollidesWith ( const Rectangle rect,
f32  x = 0,
f32  y = 0 
) const

Checks if another rectangle collides with this sprite.

Parameters:
rect The rectangle to check.
x The position of the rectangle, since x in rectangle is only an offset.
y The position of the rectangle, since y in rectangle is only an offset.
Returns:
true if it is colliding, false if not.

bool wsp::Sprite::CollidesWith ( const Sprite sprite  )  const

Checks if another sprite collides with this sprite.

Parameters:
sprite The sprite to check.
Returns:
true if it is colliding, false if not.

bool wsp::Sprite::CollidesWith ( const TiledLayer tiledlayer  )  const

Checks if the sprite does cross a tile on the tiledlayer which number is not 0.

Parameters:
tiledlayer the tiledlayer to check.
Returns:
true if it is colliding, false if not.

u32 wsp::Sprite::GetFrame (  )  const

Gets the current frame of the sprite.

Returns:
The frame this sprite is at.

u32 wsp::Sprite::GetFrameSequenceLength (  )  const

Gets how long the current frame sequence is. Same as GetRawFrameCount() if no frame sequence speficied.

void wsp::Sprite::SetFrame ( u32  sequenceIndex  ) 

Sets the current frame to a frame at the sequence.

Parameters:
sequenceIndex The index in the current frame sequence.

void wsp::Sprite::SetFrameSequence ( u32 *  sequence,
u32  length 
)

Sets the current frame sequence.

Parameters:
sequence An array with data for each sequence. Each member cannot be bigger than the maximum amount of frames.
length The length of the sequence. Gets length amount of data.


The documentation for this class was generated from the following file:

Generated on Sat Jun 14 01:36:16 2008 for libwiisprite by  doxygen 1.5.5