wsp::Sprite Class Reference
A basic drawable object with animation support.
More...
#include <sprite.h>
List of all members.
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. It is measured in degrees/2, so if 90 degrees is wanted, 45 degrees should be the passed parameter. |
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. It resets any defined stretch values.
- 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. If StretchWidth is not the same as StretchHeight, it returns 0.
- Returns:
- The current zoom of the sprite. 1 is normal size.
void wsp::Sprite::SetStretchWidth |
( |
f32 |
stretchWidth |
) |
|
Sets the width stretch of the sprite.
- Parameters:
-
| stretchWidth | Stretches the width of the sprite by this value. 1 is normal size, cannot be smaller than 0. |
void wsp::Sprite::SetStretchHeight |
( |
f32 |
stretchHeight |
) |
|
Sets the height stretch of the sprite.
- Parameters:
-
| stretchHeight | Stretches the height of the sprite by this value. 1 is normal size, cannot be smaller than 0. |
f32 wsp::Sprite::GetStretchWidth |
( |
|
) |
const |
Gets the width stretch of the sprite. Is equal to zoom value if zoom was set.
- Returns:
- The current width stretch of the sprite. 1 is normal size.
f32 wsp::Sprite::GetStretchHeight |
( |
|
) |
const |
Gets the height stretch of the sprite. Is equal to zoom vallue if zoom was set.
- Returns:
- The current height stretch 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 |
u32 wsp::Sprite::GetFrameSequencePos |
( |
|
) |
const |
u32 wsp::Sprite::GetFrameSequenceLength |
( |
|
) |
const |
u32 wsp::Sprite::GetRawFrameCount |
( |
|
) |
const |
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. |
- See also:
- Sprite - Animation Sequences
void wsp::Sprite::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.
- See also:
- Sprite - Animation Sequences
void wsp::Sprite::PrevFrame |
( |
|
) |
|
Sets the current frame to the previous frame in the sequence. Goes to the last member if the current frame is 0.
- See also:
- Sprite - Animation Sequences
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. |
- See also:
- Sprite - Animation Sequences
The documentation for this class was generated from the following file: