Polygon Dash
Loading...
Searching...
No Matches
ComponentTextRenderer Class Reference

Render the GameObject on screen as a piece of text. More...

Inheritance diagram for ComponentTextRenderer:
IComponent

Public Member Functions

 this (size_t owner, SDL_Renderer *renderer, string fontPath, int fontSize, SDL_Color color, int x, int y)
 Setup the renderer.
 
 ~this ()
 Cleanup texture memory usage.
 
override void Update ()
 Update the background texture.
 
override void Render (SDL_Renderer *renderer, SDL_Rect *camera)
 Render the text on screen.
 
bool IsVisible (SDL_Rect *camera)
 Checks whether the GameObject is visible to the camera.
 
void SetText (string newText)
 Update the text to be displayed.
 
- Public Member Functions inherited from IComponent

Public Attributes

SDL_Renderer * mRenderer
 The SDL renderer object.
 
TTF_Font * mFont
 The SDL font to use.
 
SDL_Color mColor
 The color in which to render the text.
 
SDL_Texture * mTexture
 The texture for the background.
 
SDL_Rect mRect
 Screen-space rectangle for rendering text.
 
string mText
 The text to display.
 

Detailed Description

Render the GameObject on screen as a piece of text.

The render location is defined by ComponentTransform.

See also
ComponentTransform

Constructor & Destructor Documentation

◆ this()

ComponentTextRenderer::this ( size_t owner,
SDL_Renderer * renderer,
string fontPath,
int fontSize,
SDL_Color color,
int x,
int y )
inline

Setup the renderer.

Parameters
ownerthe id of the attached GameObject.
rendererthe SDL renderer object.
fontPathpath to a TTF file containing the font to use.
fontSizethe font size to display.
colorthe color of the text.
xthe horizontal pixel position to display the text.
ythe vertical pixel position to display the text (0 is the top).

Member Function Documentation

◆ IsVisible()

bool ComponentTextRenderer::IsVisible ( SDL_Rect * camera)
inline

Checks whether the GameObject is visible to the camera.

Returns
true if visible, otherwise false.

◆ Render()

override void ComponentTextRenderer::Render ( SDL_Renderer * renderer,
SDL_Rect * camera )
inline

Render the text on screen.

Parameters
rendererthe SDL renderer to use.
camerathe SDL_Rect corresponding to the camera position and size.

Implements IComponent.

◆ SetText()

void ComponentTextRenderer::SetText ( string newText)
inline

Update the text to be displayed.

Parameters
newTextstring to display on screen.

◆ Update()

override void ComponentTextRenderer::Update ( )
inline

Update the background texture.

Implements IComponent.


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