cangine
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
cangine::Label Class Reference

Convenience game object that displays a line of text. More...

#include <label_object.hpp>

Inheritance diagram for cangine::Label:
Inheritance graph
[legend]
Collaboration diagram for cangine::Label:
Collaboration graph
[legend]

Public Member Functions

 Label (std::string text="Label", Vector3 position=Vector3(0, 0, 80))
 Constructs a label.
 
std::string getText ()
 Returns the current text.
 
Vector2 getSize ()
 Returns the rendered size of the text.
 
int getFontHeight ()
 Returns the font pixel height.
 
void setText (std::string text)
 Sets the displayed text.
 
void setFontHeight (int heightIn)
 Sets the font pixel height.
 
void setColor (Color colorIn)
 Sets the text color.
 
void setBackgroundColor (Color colorIn)
 Sets the background color behind the text.
 
TextRendererComponent * getTextRendererComponent ()
 Returns the underlying text renderer component.
 
- Public Member Functions inherited from cangine::GameObject
 GameObject ()
 
virtual ~GameObject ()
 
virtual void onUpdate (double deltaTime)
 Per-frame update hook.
 
virtual void onMouseEvent (const MouseEvent *e)
 Mouse event hook.
 
virtual void onDisable ()
 Called when the object becomes inactive.
 
virtual void onEnable ()
 Called when the object becomes active.
 
void destroy ()
 Marks the object for destruction by the ObjectManager.
 
template<typename T >
void appendComponent (T *component)
 Attaches an existing component to this object.
 
template<typename T >
void destroyComponent ()
 Destroys and removes the first component of a type.
 
template<typename T >
T * getComponent ()
 Returns the first attached component of a type.
 
template<typename T >
std::vector< T * > getComponents ()
 Returns all attached components of a type.
 
template<typename T , typename... Args>
T * newComponent (Args &&... args)
 Constructs a component in place and attaches it.
 
void setActive (bool a)
 Activates or deactivates the object.
 
bool isActive ()
 Reports whether the object is active.
 

Private Attributes

TextRendererComponent * trc = nullptr
 The underlying text renderer component.
 

Detailed Description

Convenience game object that displays a line of text.

Wraps a TextRendererComponent so callers can create on-screen text without wiring up the component manually.

Constructor & Destructor Documentation

◆ Label()

cangine::Label::Label ( std::string  text = "Label",
Vector3  position = Vector3(0, 0, 80) 
)

Constructs a label.

Parameters
textInitial text to display.
positionPosition of the label (z is the layer).

Member Function Documentation

◆ getFontHeight()

int cangine::Label::getFontHeight ( )

Returns the font pixel height.

Returns
Font height in pixels.

◆ getSize()

Vector2 cangine::Label::getSize ( )

Returns the rendered size of the text.

Returns
Width and height of the text.

◆ getText()

std::string cangine::Label::getText ( )

Returns the current text.

Returns
The displayed string.

◆ getTextRendererComponent()

TextRendererComponent * cangine::Label::getTextRendererComponent ( )

Returns the underlying text renderer component.

Returns
The label's TextRendererComponent.

◆ setBackgroundColor()

void cangine::Label::setBackgroundColor ( Color  colorIn)

Sets the background color behind the text.

Parameters
colorInNew background color.

◆ setColor()

void cangine::Label::setColor ( Color  colorIn)

Sets the text color.

Parameters
colorInNew text color.

◆ setFontHeight()

void cangine::Label::setFontHeight ( int  heightIn)

Sets the font pixel height.

Parameters
heightInNew font height in pixels.

◆ setText()

void cangine::Label::setText ( std::string  text)

Sets the displayed text.

Parameters
textNew text.

Member Data Documentation

◆ trc

TextRendererComponent* cangine::Label::trc = nullptr
private

The underlying text renderer component.


The documentation for this class was generated from the following files: