The SpriteComponent is responsible for rendering sprites on the screen.
More...
#include <SpriteComponent.h>
|
| SpriteComponent (SDL_Renderer *renderer, const char *filepath) |
| Constructs a SpriteComponent with a renderer and a file path to the sprite's texture.
|
|
virtual | ~SpriteComponent () |
| Destructor for SpriteComponent.
|
|
void | CreateSprite (const char *filepath) |
| Loads the sprite's texture from a file.
|
|
void | Render (SDL_Renderer *renderer) override |
| Renders the sprite on the screen.
|
|
void | SetW (float w) |
| Sets the sprite's width.
|
|
void | SetX (float x) |
| Sets the sprite's X position.
|
|
void | SetY (float y) |
| Sets the sprite's Y position.
|
|
float | GetX () const |
| Gets the sprite's X position.
|
|
float | GetY () const |
| Gets the sprite's Y position.
|
|
void | Move (float x, float y) |
| Moves the sprite to a new position.
|
|
SDL_FRect | GetRectangle () const |
| Gets the rectangle representing the sprite's position and size.
|
|
void | SetSize (float w, float h) |
| Sets the size of the sprite.
|
|
float | GetWidth () const |
| Gets the sprite's width.
|
|
float | GetHeight () const |
| Gets the sprite's height.
|
|
virtual void | Update (float deltaTime) |
|
The SpriteComponent is responsible for rendering sprites on the screen.
Inherits from Component and manages a texture for the sprite, including its position, size, and rendering.
◆ SpriteComponent()
SpriteComponent::SpriteComponent |
( |
SDL_Renderer * | renderer, |
|
|
const char * | filepath ) |
|
inline |
Constructs a SpriteComponent with a renderer and a file path to the sprite's texture.
- Parameters
-
renderer | The SDL renderer to use for rendering the sprite. |
filepath | The file path to the texture image. |
This constructor initializes the sprite component by loading the texture from the specified file path.
◆ CreateSprite()
void SpriteComponent::CreateSprite |
( |
const char * | filepath | ) |
|
|
inline |
Loads the sprite's texture from a file.
- Parameters
-
filepath | The file path to the texture image. |
Attempts to load the sprite's texture using the ResourceManager. If the texture is not already loaded, it loads the texture and stores it in the ResourceManager.
◆ GetHeight()
float SpriteComponent::GetHeight |
( |
| ) |
const |
|
inline |
Gets the sprite's height.
- Returns
- The current height of the sprite.
◆ GetRectangle()
SDL_FRect SpriteComponent::GetRectangle |
( |
| ) |
const |
|
inline |
Gets the rectangle representing the sprite's position and size.
- Returns
- An SDL_FRect representing the sprite's position and size.
◆ GetWidth()
float SpriteComponent::GetWidth |
( |
| ) |
const |
|
inline |
Gets the sprite's width.
- Returns
- The current width of the sprite.
◆ GetX()
float SpriteComponent::GetX |
( |
| ) |
const |
|
inline |
Gets the sprite's X position.
- Returns
- The current X position of the sprite.
◆ GetY()
float SpriteComponent::GetY |
( |
| ) |
const |
|
inline |
Gets the sprite's Y position.
- Returns
- The current Y position of the sprite.
◆ Move()
void SpriteComponent::Move |
( |
float | x, |
|
|
float | y ) |
|
inline |
Moves the sprite to a new position.
- Parameters
-
x | The new X position of the sprite. |
y | The new Y position of the sprite. |
Updates the sprite's position to the specified X and Y coordinates.
◆ Render()
void SpriteComponent::Render |
( |
SDL_Renderer * | renderer | ) |
|
|
inlineoverridevirtual |
Renders the sprite on the screen.
- Parameters
-
renderer | The SDL renderer to use for rendering the sprite. |
If the sprite's texture is loaded, this method renders the sprite at its current position and size.
Reimplemented from Component.
◆ SetSize()
void SpriteComponent::SetSize |
( |
float | w, |
|
|
float | h ) |
|
inline |
Sets the size of the sprite.
- Parameters
-
w | The width of the sprite. |
h | The height of the sprite. |
Updates the sprite's width and height to the specified values.
◆ SetW()
void SpriteComponent::SetW |
( |
float | w | ) |
|
|
inline |
Sets the sprite's width.
- Parameters
-
w | The new width of the sprite. |
◆ SetX()
void SpriteComponent::SetX |
( |
float | x | ) |
|
|
inline |
Sets the sprite's X position.
- Parameters
-
x | The new X position of the sprite. |
◆ SetY()
void SpriteComponent::SetY |
( |
float | y | ) |
|
|
inline |
Sets the sprite's Y position.
- Parameters
-
y | The new Y position of the sprite. |
The documentation for this struct was generated from the following file: