Class Engine::Sprite¶
Engine wrapper for a visual sprite, utilizing raylib::Texture to handle rendering, scaling, and rotation.
#include <Sprites.hpp>
Public Functions¶
| Type | Name |
|---|---|
| void | Draw (const raylib::Vector2 & position) Draws the sprite to the screen at the given position using its current properties (scale, rotation, source rect). |
| void | Draw (const raylib::Vector2 & position, const raylib::Color & tint) Draws the sprite with a tint color (e.g. a faded alpha for opacity). Per-call tint: safe for textures shared between entities. |
| float | GetRotation () const Gets the rotation angle of the sprite in degrees. |
| const raylib::Vector2 & | GetScale () const Gets the scale factor of the sprite. |
| const raylib::Rectangle & | GetSourceRect () const Gets the source rectangle used for drawing a specific part of the texture (useful for sprite sheets). |
| const raylib::Texture & | GetTexture () const Gets the underlying raylib texture. |
| void | SetRotation (float rot) Sets the rotation angle of the sprite. |
| void | SetScale (const raylib::Vector2 & scale) Sets the scale factor of the sprite. |
| void | SetSourceRect (const raylib::Rectangle & rect) Sets the source rectangle used for drawing a specific part of the texture. Negative width or height is allowed and flips the sprite on that axis. |
| Sprite (const std::string & path) Constructs a new Sprite object by loading a texture from a file. |
Public Functions Documentation¶
function Draw [½]¶
Draws the sprite to the screen at the given position using its current properties (scale, rotation, source rect).
Parameters:
positionThe world-space position to draw the sprite at.
function Draw [2/2]¶
Draws the sprite with a tint color (e.g. a faded alpha for opacity). Per-call tint: safe for textures shared between entities.
Parameters:
positionThe world-space position to draw the sprite at.tintColor multiplier applied to every pixel.
function GetRotation¶
Gets the rotation angle of the sprite in degrees.
Returns:
The rotation angle.
function GetScale¶
Gets the scale factor of the sprite.
Returns:
Constant reference to the scale vector.
function GetSourceRect¶
Gets the source rectangle used for drawing a specific part of the texture (useful for sprite sheets).
Returns:
Constant reference to the source raylib::Rectangle.
function GetTexture¶
Gets the underlying raylib texture.
Returns:
Constant reference to the raylib::Texture.
function SetRotation¶
Sets the rotation angle of the sprite.
Parameters:
rotThe new rotation angle in degrees.
function SetScale¶
Sets the scale factor of the sprite.
Parameters:
scaleThe new scale vector.
Exception:
- ErrorAsset If either component is less than or equal to 0.
function SetSourceRect¶
Sets the source rectangle used for drawing a specific part of the texture. Negative width or height is allowed and flips the sprite on that axis.
Parameters:
rectThe new source rectangle.
Exception:
- ErrorAsset If width or height is 0, or if the rectangle lies outside the texture.
function Sprite¶
Constructs a new Sprite object by loading a texture from a file.
Parameters:
pathThe file path to the image file.
The documentation for this class was generated from the following file /home/runner/work/r-type/r-type/Engine/include/Assets/Sprites.hpp