NWengine 0.9
Loading...
Searching...
No Matches
Text Class Reference

The Text class represents a text component that can be attached to a GameObject. More...

#include <Text.h>

Inheritance diagram for Text:
GameComponent Serialized

Public Member Functions

 Text ()=default
 Text constructor.
 
 ~Text ()
 Text destructor.
 
 Text (GameObject *go)
 Text constructor with GameObject parameter.
 
void Update () override
 Update is called every frame to update the Text component.
 
voidGetGameObject () override
 GetGameObject returns the GameObject that the Text component is attached to.
 
void SetGameObject (void *go) override
 SetGameObject sets the GameObject that the Text component is attached to.
 
void UpdateGlyphs ()
 UpdateGlyphs updates the glyphs of the Text component.
 
void SetFont (const std::string &path, Shader *shader)
 SetFont sets the font of the Text component.
 
void SetShader (Shader *shader)
 SetShader sets the shader of the Text component.
 
fVec2 GetSize ()
 Gets total size in pixels sets the shader of the text.
 
int Serialize (std::fstream *data, int offset) override
 Serialize serializes the Text component data.
 
int Deserialize (std::fstream *data, int offset) override
 Deserialize deserializes the Text component data.
 
- Public Member Functions inherited from GameComponent
virtual void Start ()
 Start the game component.
 
virtual ~GameComponent ()
 Destructor for the game component.
 
- Public Member Functions inherited from Serialized
 Serialized ()
 Default constructor for Serialized class.
 

Static Public Member Functions

static std::string GetType ()
 GetType returns the type of the Text component.
 
- Static Public Member Functions inherited from GameComponent
static std::string GetType ()
 Get the type of the game component.
 

Public Attributes

GameObjectattachedObj = nullptr
 attachedObj is a pointer to the GameObject that the Text component is attached to.
 
std::list< Charactercharacters
 characters is a list of characters that make up the text.
 
Shader_shader = nullptr
 _shader is a pointer to the shader used for rendering the text.
 
Fontfont = nullptr
 font is a pointer to the font used for rendering the text.
 
std::string text = ""
 text is the string of text to be rendered.
 
bool isBatched = true
 isBatched indicates whether the text is batched for rendering.
 
int layerOrder = 0
 layerOrder indicates the layer order of each glyph, changing this requires calling UpdateGlyph()
 
Vector4< floatcolors = Vector4<float>(1.0f, 1.0f, 1.0f, 1.0f)
 colors is the color of the text.
 
fVec2 position = fVec2(0.0f, 0.0f)
 position is the position of the text.
 
fVec2 scale = fVec2(1.0f, 1.0f)
 scale is the scale of the text.
 

Detailed Description

The Text class represents a text component that can be attached to a GameObject.

Represents a text component that can be attached to a game object.

Constructor & Destructor Documentation

◆ Text()

Text::Text ( GameObject * go)

Text constructor with GameObject parameter.

Parameters
goThe GameObject to attach the Text component to.

Member Function Documentation

◆ Deserialize()

int Text::Deserialize ( std::fstream * data,
int offset )
overridevirtual

Deserialize deserializes the Text component data.

Parameters
dataThe file stream to read the serialized data from.
offsetThe offset in the file stream to start reading the serialized data.
Returns
The offset in the file stream after reading the serialized data.

Reimplemented from Serialized.

◆ GetGameObject()

void * Text::GetGameObject ( )
overridevirtual

GetGameObject returns the GameObject that the Text component is attached to.

Returns
The GameObject that the Text component is attached to.

Reimplemented from GameComponent.

◆ GetSize()

fVec2 Text::GetSize ( )

Gets total size in pixels sets the shader of the text.

Returns
vector of size in pixels.
Note
Only horizontal size is tested.

◆ GetType()

static std::string Text::GetType ( )
inlinestatic

GetType returns the type of the Text component.

Returns
The type of the Text component.

◆ Serialize()

int Text::Serialize ( std::fstream * data,
int offset )
overridevirtual

Serialize serializes the Text component data.

Parameters
dataThe file stream to write the serialized data to.
offsetThe offset in the file stream to start writing the serialized data.
Returns
The offset in the file stream after writing the serialized data.

Reimplemented from Serialized.

◆ SetFont()

void Text::SetFont ( const std::string & path,
Shader * shader )

SetFont sets the font of the Text component.

Parameters
pathThe path to the font file.
shaderThe shader to use for rendering the text.

◆ SetGameObject()

void Text::SetGameObject ( void * go)
overridevirtual

SetGameObject sets the GameObject that the Text component is attached to.

Parameters
goThe GameObject to attach the Text component to.

Reimplemented from GameComponent.

◆ SetShader()

void Text::SetShader ( Shader * shader)

SetShader sets the shader of the Text component.

Parameters
shaderThe shader to use for rendering the text.

◆ Update()

void Text::Update ( )
overridevirtual

Update is called every frame to update the Text component.

Reimplemented from GameComponent.


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