LPCGame
A Simple 2d Game Engine
 All Classes Namespaces Functions Variables Enumerations Enumerator Pages
Text Class Reference

Handles drawing some text. More...

#include <text.h>

Public Member Functions

 Text (std::string message, std::string font, Color color, int fontSize=30)
 
void Set (std::string message, std::string font, Color color, int fontSize=30)
 
void SetMessage (std::string message)
 
void SetFont (std::string font)
 
void SetFontSize (int fontSize)
 
void SetColor (Color color)
 
std::string GetMessage ()
 
std::string GetFont ()
 
int GetFontSize ()
 
Color GetColor ()
 
SDL_Texture * Texture ()
 
Recti Size () const
 
void Size (int *w, int *h=NULL) const
 
int W () const
 Get the width of the text.
 
int H () const
 Get the height.
 
Json::Value Save () const
 
void Load (Json::Value val)
 

Detailed Description

Handles drawing some text.

A simple class for drawing a string to a texture with some color and a specified TTF_Font and font size

Constructor & Destructor Documentation

Text::Text ( std::string  message,
std::string  font,
Color  color,
int  fontSize = 30 
)

Setup the text object with a message, font and font size

Parameters
messageThe message to be displayed
fontThe font file to use
fontSizeThe font size to use, default is 30
colorThe color of font to use, default is black

Member Function Documentation

Color Text::GetColor ( )

Get the current text color

Returns
the text color
std::string Text::GetFont ( )

Get the font file currently being used

Returns
the font file path
int Text::GetFontSize ( )

Get the font size currently being used

Returns
the current font size
std::string Text::GetMessage ( )

Get the message text being displayed

Returns
the message
void Text::Load ( Json::Value  val)

Load the text data from a Json::Value

Parameters
valThe Json::Value to load from
Json::Value Text::Save ( ) const

Save the text data to a Json::Value

Returns
Json::Value containing information about the text
void Text::Set ( std::string  message,
std::string  font,
Color  color,
int  fontSize = 30 
)

Set a message, font and font size

Parameters
messageThe message to be displayed
fontThe font file to use
fontSizeThe font size to use, default is 30
colorThe color of font to use, default is black
void Text::SetColor ( Color  color)

Set the font color to use, checks to make sure color is different before redrawing

Parameters
colorThe color to use
void Text::SetFont ( std::string  font)

Set a font for the text to use, checks to make sure font is different before loading the new font and rendering message

Parameters
fontThe font file to use
void Text::SetFontSize ( int  fontSize)

Set the font size to use, checks to make sure size is different before reloading the font with the new size

Parameters
fontSizeThe font size to use
void Text::SetMessage ( std::string  message)

Set a message for the text, checks to make sure message is different before rendering the new message

Parameters
messageThe message to display
Recti Text::Size ( ) const

Get a rect containing the message texture's width and height

Returns
Recti containing the width and height of the message
void Text::Size ( int *  w,
int *  h = NULL 
) const

Store the width and height values of the texture in the values passed

Parameters
wThe value to store the width in
hThe value to store the height in
SDL_Texture * Text::Texture ( )

Get the texture pointer of the font, used for the window's draw functions

See Also
Window
Returns
The message's SDL_Texture pointer

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