Wraith
0.1.5
Basic 3D game engine in C++
|
A Sprite entity is used for displaying a 2D image on the screen. It can be used anywhere within a user defined GameObject. More...
Functions | |
Sprite::Sprite (const std::string &imageKey) | |
Constructs sprite using image key defined within Image Manager. More... | |
void | Sprite::render () |
Renders this sprite. More... | |
void | Sprite::setPosition (float positionX, float positionY) |
Sets sprite position. More... | |
float | Sprite::getPositionX () const |
Gets position x coordinate. More... | |
void | Sprite::setCenter (float centerX, float centerY) |
Sets sprite center. More... | |
void | Sprite::setAngle (float angle) |
Sets sprite angle./ More... | |
float | Sprite::getAngle () const |
Gets the sprite angle. More... | |
void | Sprite::offsetAngle (float angleOffset) |
Offset sprite angle. More... | |
void | Sprite::setScaleFactor (float scaleX, float scaleY) |
Sets scale factor. More... | |
void | Sprite::setScalePixel (float width, float height) |
Sets scale pixel. More... | |
float | Sprite::getWidth () const |
Gets the width of the sprite. More... | |
float | Sprite::getHeight () const |
Gets the height of the sprite. More... | |
A Sprite entity is used for displaying a 2D image on the screen. It can be used anywhere within a user defined GameObject.
The Sprite's constructor must take in a imageKey, a key used to assign to a particular image within the ImageManager, in order to create Sprite entity.
IMPORTANT: To render a Sprite entity, it you must call Sprite::render() within the GameObject::draw2D() callback in order to display the sprite properly.
Here is an example of how a sprite can be used.
float Sprite::getAngle | ( | ) | const |
Gets the sprite angle.
angle is in radians.
float Sprite::getHeight | ( | ) | const |
Gets the height of the sprite.
float Sprite::getPositionX | ( | ) | const |
Gets position x coordinate.
float Sprite::getWidth | ( | ) | const |
Gets the width of the sprite.
void Sprite::offsetAngle | ( | float | angleOffset | ) |
Offset sprite angle.
angle offset is in radians.
angleOffset | The angle offset. |
void Sprite::render | ( | ) |
Renders this sprite.
must be called within GameObject::draw2D() of the user derived GameObject entity.
void Sprite::setAngle | ( | float | angle | ) |
Sets sprite angle./
angle is in radians.
angle | The angle. |
void Sprite::setCenter | ( | float | centerX, |
float | centerY | ||
) |
Sets sprite center.
the (0, 0) center is the actual center of the sprite image.
centerX | The center x coordinate. |
centerY | The center y coordinate. |
void Sprite::setPosition | ( | float | positionX, |
float | positionY | ||
) |
Sets sprite position.
The (0, 0) position is the lower left corner of the screen.
positionX | The position x coordinate. |
positionY | The position y coordinate. |
void Sprite::setScaleFactor | ( | float | scaleX, |
float | scaleY | ||
) |
Sets scale factor.
scaleX | The X scale factor. |
scaleY | The Y scale factor. |
void Sprite::setScalePixel | ( | float | width, |
float | height | ||
) |
Sets scale pixel.
width | The width. |
height | The height. |
Sprite::Sprite | ( | const std::string & | imageKey | ) |
Constructs sprite using image key defined within Image Manager.
The key is one that used to assign a particular image in ImageManager.
imageKey | The image key. |