A sprite is a texture with vertex data.
More...
#include <Sprite.hpp>
|
| Sprite () |
| Constructor.
|
|
| Sprite (const nlohmann::json &json) |
| JSON constructor.
|
|
| Sprite (Sprite &&) |
| Move constructor.
|
|
Sprite & | operator= (Sprite &&) |
| Move assignment operator.
|
|
virtual | ~Sprite () |
| Destructor.
|
|
void | set_texture (const std::string &texture) |
| Sets the texture and vertex data.
|
|
void | set_texture (const std::string &texture, const math::fRect &rect) |
| Sets the texture and vertex data.
|
|
void | set_clip (const math::fRect &rect) |
| Set texture clip.
|
|
const math::fRect & | get_clip () const |
| Get texture clip.
|
|
graphics::Texture2D * | get_texture () |
| Get texture.
|
|
const std::string & | get_texture_name () const |
| Texture name.
|
|
nlohmann::json | serialize () override |
| Serializes object.
|
|
void | deserialize (const nlohmann::json &json) override |
| Deserializes from object.
|
|
A sprite is a texture with vertex data.
Definition at line 24 of file Sprite.hpp.
◆ Sprite() [1/4]
galaxy::components::Sprite::Sprite |
( |
| ) |
|
◆ Sprite() [2/4]
galaxy::components::Sprite::Sprite |
( |
const nlohmann::json & | json | ) |
|
JSON constructor.
- Parameters
-
json | JSON defining object. |
Definition at line 26 of file Sprite.cpp.
◆ Sprite() [3/4]
galaxy::components::Sprite::Sprite |
( |
Sprite && | s | ) |
|
◆ ~Sprite()
galaxy::components::Sprite::~Sprite |
( |
| ) |
|
|
virtual |
◆ Sprite() [4/4]
galaxy::components::Sprite::Sprite |
( |
const Sprite & | | ) |
|
|
privatedelete |
◆ operator=() [1/2]
Sprite & galaxy::components::Sprite::operator= |
( |
Sprite && | s | ) |
|
Move assignment operator.
Definition at line 51 of file Sprite.cpp.
◆ set_texture() [1/2]
void galaxy::components::Sprite::set_texture |
( |
const std::string & | texture | ) |
|
Sets the texture and vertex data.
- Parameters
-
Definition at line 82 of file Sprite.cpp.
◆ set_texture() [2/2]
void galaxy::components::Sprite::set_texture |
( |
const std::string & | texture, |
|
|
const math::fRect & | rect ) |
Sets the texture and vertex data.
- Parameters
-
texture | Texture file in VFS. |
rect | Custom region on a texture to render from. |
Definition at line 112 of file Sprite.cpp.
◆ set_clip()
void galaxy::components::Sprite::set_clip |
( |
const math::fRect & | rect | ) |
|
Set texture clip.
- Parameters
-
rect | Coords on sprite to clip to. |
Definition at line 161 of file Sprite.cpp.
◆ get_clip()
const math::fRect & galaxy::components::Sprite::get_clip |
( |
| ) |
const |
|
nodiscard |
Get texture clip.
- Returns
- Const reference to sprite clip.
Definition at line 193 of file Sprite.cpp.
◆ get_texture()
graphics::Texture2D * galaxy::components::Sprite::get_texture |
( |
| ) |
|
|
nodiscard |
Get texture.
- Returns
- Pointer. DO NOT STORE THIS.
Definition at line 198 of file Sprite.cpp.
◆ get_texture_name()
const std::string & galaxy::components::Sprite::get_texture_name |
( |
| ) |
const |
|
nodiscard |
◆ serialize()
nlohmann::json galaxy::components::Sprite::serialize |
( |
| ) |
|
|
nodiscardoverride |
Serializes object.
- Returns
- JSON object containing data to be serialized.
Definition at line 208 of file Sprite.cpp.
◆ deserialize()
void galaxy::components::Sprite::deserialize |
( |
const nlohmann::json & | json | ) |
|
|
override |
Deserializes from object.
- Parameters
-
json | Json object to retrieve data from. |
Definition at line 220 of file Sprite.cpp.
◆ operator=() [2/2]
Sprite & galaxy::components::Sprite::operator= |
( |
const Sprite & | | ) |
|
|
privatedelete |
Copy assignment operator.
◆ m_vao
graphics::VertexArray galaxy::components::Sprite::m_vao |
◆ m_tint
graphics::Colour galaxy::components::Sprite::m_tint |
◆ m_texture
graphics::Texture2D* galaxy::components::Sprite::m_texture |
|
private |
◆ m_name
std::string galaxy::components::Sprite::m_name |
|
private |
◆ m_vertices
std::array<graphics::Vertex, 4> galaxy::components::Sprite::m_vertices |
|
private |
◆ m_clip
math::fRect galaxy::components::Sprite::m_clip |
|
private |
The documentation for this class was generated from the following files: