Component that represents a 2D sprite to be rendered. The Sprite component holds a reference to a Texture and includes properties for flipping, sorting, ordering, and color modulation. It can be treated as a wrapper around a texture with additional rendering properties that go beyond just the texture itself.
More...
#include <sprite.h>
Component that represents a 2D sprite to be rendered. The Sprite component holds a reference to a Texture and includes properties for flipping, sorting, ordering, and color modulation. It can be treated as a wrapper around a texture with additional rendering properties that go beyond just the texture itself.
Usage:
- Create a Sprite component with a texture name and desired properties.
- Attach the Sprite to a GameObject to have it rendered.
- Modify properties such as flip_x, flip_y, sorting_layer, ordering_layer, and color as needed.
- Note
- Ensure the specified texture exists in the asset resource.
◆ Sprite()
| Sprite::Sprite |
( |
const std::string & |
sprite, |
|
|
Color |
color, |
|
|
bool |
flip_x, |
|
|
bool |
flip_y, |
|
|
int |
sorting_layer, |
|
|
int |
ordering_layer |
|
) |
| |
◆ color() [1/2]
| Color Sprite::color |
( |
| ) |
const |
◆ color() [2/2]
◆ flip_x() [1/2]
| bool Sprite::flip_x |
( |
| ) |
const |
◆ flip_x() [2/2]
| Sprite & Sprite::flip_x |
( |
bool |
val | ) |
|
◆ flip_y() [1/2]
| bool Sprite::flip_y |
( |
| ) |
const |
◆ flip_y() [2/2]
| Sprite & Sprite::flip_y |
( |
bool |
val | ) |
|
◆ ordering_layer() [1/2]
| int Sprite::ordering_layer |
( |
| ) |
const |
◆ ordering_layer() [2/2]
| Sprite & Sprite::ordering_layer |
( |
int |
val | ) |
|
◆ sorting_layer() [1/2]
| int Sprite::sorting_layer |
( |
| ) |
const |
◆ sorting_layer() [2/2]
| Sprite & Sprite::sorting_layer |
( |
int |
val | ) |
|
◆ texture() [1/3]
| const Texture & Sprite::texture |
( |
| ) |
const |
◆ texture() [2/3]
| Sprite & Sprite::texture |
( |
const std::string & |
name | ) |
|
◆ texture() [3/3]
◆ type_name()
| std::string Sprite::type_name |
( |
| ) |
const |
|
overridevirtual |
Provides a consistent type name for the component.
- Returns
- A string representing the type name of the component. @CAUTION: All derived components must implement this method to ensure consistent serialization across different compilers and platforms.
Reimplemented from Renderable.
◆ update()
| void Sprite::update |
( |
float |
dt | ) |
|
|
overridevirtual |
The documentation for this class was generated from the following file:
- include/engine/public/components/sprite.h