![]() |
Calamity Engine 1.0.0
A cross-platform 2D game engine written in C++ and SDL3.
|
#include <label.hpp>
Public Member Functions | |
| Label (const std::string &text, std::shared_ptr< Font > font) | |
| Label (const std::string &text) | |
| Label () | |
| ~Label () | |
| void | update (float dt) |
| void | render (std::shared_ptr< Window > window) |
| Label * | setText (const std::string &text) |
| std::string | getText () const |
| TTF_Text * | getHandle () const |
| Label * | setColor (Color color) |
| Color | getColor () const |
| Label * | setDirection (FontDirection direction) |
| Label * | setWrapWidth (int width) |
| int | getWrapWidth () const |
| void | rebuildTexture () |
| SDL_Texture * | getTexture () const |
| template<class Archive > | |
| void | save (Archive &ar) const |
| template<class Archive > | |
| void | load (Archive &ar) |
Public Member Functions inherited from Component | |
| virtual | ~Component ()=default |
| virtual void | initialize () |
| virtual void | physicsUpdate () |
| virtual void | input (InputEvent &event) |
| virtual void | postLoad () |
| virtual void | exit () |
| Node * | getNode () const |
| void | setNode (Node *n) |
| template<class Archive > | |
| void | save (Archive &ar) const |
| template<class Archive > | |
| void | load (Archive &ar) |
Public Attributes | |
| Vector2 | size |
| Vector2 | origin |
| std::shared_ptr< Font > | font |
| bool | visible = true |
| bool | wrap = true |
| bool | screenSpace = false |
The Label component renders text to the screen. You can construct it with or without a font, in which case a default font will be used.
Example Usage:
You can change the Label components origin. I'm really tired of saying what origin does over and over again...
The Label component also exposes a wrap attribute. This defines if the text is rendered using text wrap or not.
You can also make Labels render using screen space positioning. This can be used for UI elements and things like that:
You can also...
Make sure to also check out the text example!
| Label::Label | ( | const std::string & | text, |
| std::shared_ptr< Font > | font | ||
| ) |
| Label::Label | ( | const std::string & | text | ) |
| Label::Label | ( | ) |
| Label::~Label | ( | ) |
| Color Label::getColor | ( | ) | const |
| TTF_Text * Label::getHandle | ( | ) | const |
| std::string Label::getText | ( | ) | const |
| SDL_Texture * Label::getTexture | ( | ) | const |
| int Label::getWrapWidth | ( | ) | const |
|
inline |
| void Label::rebuildTexture | ( | ) |
|
inline |
| Label * Label::setDirection | ( | FontDirection | direction | ) |
| Label * Label::setText | ( | const std::string & | text | ) |
| Label * Label::setWrapWidth | ( | int | width | ) |
|
virtual |
Reimplemented from Component.
| std::shared_ptr<Font> Label::font |
| Vector2 Label::origin |
| bool Label::screenSpace = false |
| Vector2 Label::size |
| bool Label::visible = true |
| bool Label::wrap = true |