Nox Engine
 
Loading...
Searching...
No Matches
Text Struct Reference

A component that renders a string of text on the screen. More...

#include <Text.h>

Inheritance diagram for Text:
Inheritance graph
Collaboration diagram for Text:
Collaboration graph

Public Member Functions

 Text (std::string inStr, int x, int y, float scale, SDL_Color color)
 Constructs a fully customized Text component.
 
 Text (std::string inStr, int x, int y, float scale)
 Constructs a Text component with a default color.
 
 Text (std::string inStr, int x, int y)
 Constructs a Text component with a default color and scale.
 
void update () override
 Updates the destination rectangle for rendering.
 
void draw () override
 Draws the text texture to the screen.
 
void changeText (std::string text)
 Changes the text content and regenerates the texture.
 
void centreText (SDL_Rect &parentRect)
 Adjusts the text's position to be centered within a parent rectangle.
 
- Public Member Functions inherited from Component
virtual void init ()
 Called once when the component is added to an entity.
 
virtual void reload ()
 Called to reset the component's state.
 

Protected Member Functions

void setTex (const char *text)
 Creates a new texture from a string of text.
 

Protected Attributes

std::string data
 
float scale
 
SDL_TexturetextTex
 
SDL_Colour textColour
 
SDL_Rect destRect
 

Additional Inherited Members

- Public Attributes inherited from Component
Entityentity
 Pointer to the entity that owns this component.
 

Detailed Description

A component that renders a string of text on the screen.

Wraps SDL_ttf to create a texture from a string and displays it.

Constructor & Destructor Documentation

◆ Text() [1/3]

Text::Text ( std::string  inStr,
int  x,
int  y,
float  scale,
SDL_Color  color 
)

Constructs a fully customized Text component.

Parameters
inStrThe initial string to display.
xThe x-position.
yThe y-position.
scaleThe rendering scale.
colorThe color of the text.
Here is the call graph for this function:

◆ Text() [2/3]

Text::Text ( std::string  inStr,
int  x,
int  y,
float  scale 
)

Constructs a Text component with a default color.

Parameters
inStrThe initial string to display.
xThe x-position.
yThe y-position.
scaleThe rendering scale.
Here is the call graph for this function:

◆ Text() [3/3]

Text::Text ( std::string  inStr,
int  x,
int  y 
)

Constructs a Text component with a default color and scale.

Parameters
inStrThe initial string to display.
xThe x-position.
yThe y-position.
Here is the call graph for this function:

Member Function Documentation

◆ centreText()

void Text::centreText ( SDL_Rect parentRect)

Adjusts the text's position to be centered within a parent rectangle.

Parameters
parentRectThe rectangle to center within.
Here is the call graph for this function:

◆ changeText()

void Text::changeText ( std::string  text)

Changes the text content and regenerates the texture.

Parameters
textThe new string to display.

◆ draw()

void Text::draw ( )
overridevirtual

Draws the text texture to the screen.

Reimplemented from Component.

Here is the call graph for this function:

◆ setTex()

void Text::setTex ( const char text)
protected

Creates a new texture from a string of text.

Parameters
textThe string to render.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ update()

void Text::update ( )
overridevirtual

Updates the destination rectangle for rendering.

Reimplemented from Component.

Here is the call graph for this function:

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