raylibstarter 0.1.0
|
The Sprite class specifies position and degree of rotation on the screen for an associated VRAM texture. More...
#include <sprite.h>
Public Member Functions | |
Sprite ()=delete | |
Sprite (std::shared_ptr< game::core::Texture2D > texture) | |
Constructor. More... | |
Sprite (std::shared_ptr< game::core::Texture2D > texture, int pos_x, int pos_y) | |
Constructor. More... | |
Sprite (std::shared_ptr< game::core::Texture2D > texture, int pos_x, int pos_y, float rotation) | |
Constructor. More... | |
Sprite (std::shared_ptr< game::core::Texture2D > texture, int pos_x, int pos_y, Vector2 rotation_origin, float rotation, Rectangle frame) | |
Constructor. More... | |
virtual | ~Sprite () |
void | texture (const std::shared_ptr< game::core::Texture2D > &texture) |
Replaces the Texture2D object. More... | |
const std::shared_ptr< game::core::Texture2D > & | texture_object () const |
const ::Texture2D & | texture () const |
Vector2 | position () const |
const Rectangle & | frame () const |
void | frame (const Rectangle &frame) |
Sets the section of the associated VRAM texture to be displayed. More... | |
virtual void | Update () |
Public Attributes | |
bool | visible = true |
Visibility of the Sprite. More... | |
Color | tint = WHITE |
The Raylib tint applied to the VRAM texture when drawing. Defulat ist Raylib WHITE. More... | |
Vector2 | rotation_origin |
The sprites rotation origin, centered by default. More... | |
float | rotation = 0.0f |
The sprites rotation angle. Default is 0. More... | |
int | pos_x = 0 |
The sprites x position. More... | |
int | pos_y = 0 |
The sprites y position. More... | |
Protected Attributes | |
std::shared_ptr< game::core::Texture2D > | texture_ |
The sprites Texture2D. More... | |
Rectangle | frame_ |
The section of the associated VRAM texture to be displayed as Raylib Rectangle structure. More... | |
The Sprite class specifies position and degree of rotation on the screen for an associated VRAM texture.
Besides the position and rotation angle, a sprite object is further defined by its rotation origin, its tint and its visibility attribute. In addition, the visible section ("frame") of the associated VRAM texture can be specified. This is especially important for the SpriteAnimated class derived from this class.
Sprites can be drawn using the game::core::Renderer::DrawTexture function. However, the preferred way is to create Actor objects. These contain a sprite and are automatically drawn if they are referenced in the actors map of a Scene object.
|
delete |
|
explicit |
Constructor.
This constructor sets the section of the texture to be displayed to its full size. In addition, the rotation origin is set to its center and rotation angle = 0. The sprites default position is {0, 0}.
texture | Shared pointer to a Texture2D object. |
Definition at line 7 of file sprite.cpp.
game::core::Sprite::Sprite | ( | std::shared_ptr< game::core::Texture2D > | texture, |
int | pos_x, | ||
int | pos_y | ||
) |
Constructor.
This constructor sets the section of the texture to be displayed to its full size. In addition, the rotation origin is set to its center and rotation angle = 0. The sprites position can be specified.
texture | Shared pointer to a Texture2D object. |
pos_x | The sprites x position. |
pos_y | The sprites y position. |
Definition at line 12 of file sprite.cpp.
game::core::Sprite::Sprite | ( | std::shared_ptr< game::core::Texture2D > | texture, |
int | pos_x, | ||
int | pos_y, | ||
float | rotation | ||
) |
Constructor.
This constructor sets the section of the texture to be displayed to its full size. In addition, the rotation origin is set to its center. The sprites position and rotation angle can be specified.
texture | Shared pointer to a Texture2D object. |
pos_x | The sprites x position. |
pos_y | The sprites y position. |
rotation | The sprites rotation angle. |
Definition at line 17 of file sprite.cpp.
game::core::Sprite::Sprite | ( | std::shared_ptr< game::core::Texture2D > | texture, |
int | pos_x, | ||
int | pos_y, | ||
Vector2 | rotation_origin, | ||
float | rotation, | ||
Rectangle | frame | ||
) |
Constructor.
Using this constructor the sprites position, rotation angle and rotation and a Raylib Rectangle, which describes the texture section to be displayed can be specified.
texture | Shared pointer to a Texture2D object. |
pos_x | The sprites x position. |
pos_y | The sprites y position. |
rotation_origin | The rotation origin. |
rotation | The sprites rotation angle. |
frame | The section of the associated VRAM texture to be displayed. |
Definition at line 31 of file sprite.cpp.
|
virtual |
Definition at line 41 of file sprite.cpp.
const Rectangle & game::core::Sprite::frame | ( | ) | const |
Definition at line 67 of file sprite.cpp.
void game::core::Sprite::frame | ( | const Rectangle & | frame | ) |
Sets the section of the associated VRAM texture to be displayed.
frame | Raylib Rectangle, which describes the texture section to be displayed. |
Definition at line 71 of file sprite.cpp.
Vector2 game::core::Sprite::position | ( | ) | const |
Definition at line 45 of file sprite.cpp.
const ::Texture2D & game::core::Sprite::texture | ( | ) | const |
Definition at line 63 of file sprite.cpp.
void game::core::Sprite::texture | ( | const std::shared_ptr< game::core::Texture2D > & | texture | ) |
Replaces the Texture2D object.
The section of the texture to be displayed is set to its full size. In addition, the rotation origin is set to its center.
texture | Shared pointer to a Texture2D object. |
Definition at line 53 of file sprite.cpp.
const std::shared_ptr< game::core::Texture2D > & game::core::Sprite::texture_object | ( | ) | const |
Definition at line 49 of file sprite.cpp.
|
inlinevirtual |
Only relevant in derived classes, like SpiteAnimated.
Reimplemented in game::core::SpriteAnimated.
|
protected |
float game::core::Sprite::rotation = 0.0f |
Vector2 game::core::Sprite::rotation_origin |
|
protected |
Color game::core::Sprite::tint = WHITE |
bool game::core::Sprite::visible = true |