Sprite class for making and rendering 2D sprites. More...
#include <IonSprite.h>
Inherits Align16.
Detailed Description
Sprite class for making and rendering 2D sprites.
The IonSprite Object allows users to implement 2D sprites. When IonSprite's are created they are given an Image to render (which can be loaded in LoadResources.cpp).
NOTE: The IonSprite Render() function will need to be called in the Draw2D() function of a Drawable class.
Public Member Functions | |
IonSprite (Image *input_image) | |
The IonSprite constructor takes in an Image pointer for it's sprite. More... | |
void | SetAngle (const float &angle) |
Function that sets the rotation angle of the sprite. More... | |
void | SetScale (const float &scale_width, const float &scale_height) |
Function that sets the scale of the sprite's width and height. More... | |
void | SetPosition (const float &x_cord, const float &y_cord) |
Function that sets the position of the sprite on the screen. More... | |
void | SetCenter (const float &x_cord_offset, const float &y_cord_offset) |
Function that sets the center position of the sprite. More... | |
void | Render () |
Function that renders the Sprite to the 2D camera. | |
float | getAngle () |
Function that get's the sprite's angle of rotation. More... | |
Constructor & Destructor Documentation
IonSprite::IonSprite | ( | Image * | input_image | ) |
The IonSprite constructor takes in an Image pointer for it's sprite.
For creating Images, see the ImageManager::Load() and ImageManager::Get() functions. Images can be loaded into the LoadResources.cpp for access later when constructing an IonSprite.
- Parameters
-
input_image An Image pointer to reference for this sprite.
Member Function Documentation
float IonSprite::getAngle | ( | ) |
Function that get's the sprite's angle of rotation.
- Returns
- Float of the sprite's current angle in RADIANS.
void IonSprite::SetAngle | ( | const float & | angle | ) |
Function that sets the rotation angle of the sprite.
- Parameters
-
angle A float in RADIANS for setting the angle.
void IonSprite::SetCenter | ( | const float & | x_cord_offset, |
const float & | y_cord_offset | ||
) |
Function that sets the center position of the sprite.
The center of the sprite is locally defined as 0,0. This function will offset the X coord and Y coord of the center by a desired amount. This allows for rotation around a different coordinate.
- Parameters
-
x_cord_offset A float offset for the X coordinate center position. y_cord_offset A float offset for the Y coordinate center position.
void IonSprite::SetPosition | ( | const float & | x_cord, |
const float & | y_cord | ||
) |
Function that sets the position of the sprite on the screen.
- Parameters
-
x_cord A float for the X coordinate position on the screen. y_cord A float for the Y coordinate position on the screen.
void IonSprite::SetScale | ( | const float & | scale_width, |
const float & | scale_height | ||
) |
Function that sets the scale of the sprite's width and height.
- Parameters
-
scale_width A float for scaling the width. scale_height A float for scaling the height