Angel
A 2D Game Prototyping Engine
Classes | Public Member Functions
TextActor Class Reference

An Actor for displaying text on the screen. More...

#include <TextActor.h>

+ Inheritance diagram for TextActor:

List of all members.

Classes

struct  TextNugget

Public Member Functions

 TextActor (const String &fontNickname="Console", const String &displayString="", TextAlignment align=TXT_Left, int lineSpacing=5)
virtual void Render ()
const String & GetFont () const
void SetFont (const String &newFont)
const String & GetDisplayString () const
void SetDisplayString (const String &newString)
const TextAlignment GetAlignment ()
void SetAlignment (TextAlignment newAlignment)
const int GetLineSpacing ()
void SetLineSpacing (int newSpacing)
virtual void SetPosition (float x, float y)
virtual void SetPosition (const Vector2 &position)
virtual void SetRotation (float newRotation)
virtual void ReceiveMessage (Message *message)
const BoundingBoxGetBoundingBox () const
virtual const String GetClassName () const

Detailed Description

A TextActor handles drawing text to the screen using world coordinates. The basis text rendering functions operate in screen-space, which can be annoying if you want to have debug data or labels for your Actors.

In addition, a TextActor supports wraps up more functionality than the simple text rendering, allowing varying alignments, newlines, etc.

Definition at line 54 of file TextActor.h.


Constructor & Destructor Documentation

TextActor::TextActor ( const String &  fontNickname = "Console",
const String &  displayString = "",
TextAlignment  align = TXT_Left,
int  lineSpacing = 5 
)

The constructor sets up all the textual information that this TextActor will use to draw itself to the screen.

Parameters:
fontNicknamethe name of the font to be used when drawing this TextActor. The name of the font is set with the RegisterFont function. By default it uses the monospaced font used in the Console, at 24 points.
displayStringthe actual text to be displayed
alignthe desired alignment of the text
lineSpacingthe amount of space (in pixels) between each line of text

Definition at line 40 of file TextActor.cpp.


Member Function Documentation

void TextActor::Render ( ) [virtual]

Override of the Renderable::Render function to draw text

Reimplemented from Actor.

Definition at line 55 of file TextActor.cpp.

const String & TextActor::GetFont ( ) const

Get the name of the font currently being used for this Actor

Returns:
the nickname of the current font, as set in RegisterFont

Definition at line 64 of file TextActor.cpp.

void TextActor::SetFont ( const String &  newFont)

Change the font used in drawing this TextActor.

Parameters:
newFontthe nickname of the new font. This must be set up with RegisterFont before being set here -- the TextActor will not draw at all if this is an invalid nickname.

Definition at line 69 of file TextActor.cpp.

const String & TextActor::GetDisplayString ( ) const

Get the current string being drawn by this TextActor.

Returns:
the display string

Definition at line 75 of file TextActor.cpp.

void TextActor::SetDisplayString ( const String &  newString)

Change the string to be drawn by this TextActor. Newlines can be delimited with the plain newline character (\n).

Parameters:
newStringthe string that should be drawn by this TextActor in the next frame

Definition at line 80 of file TextActor.cpp.

const TextAlignment TextActor::GetAlignment ( )

Get the current alignment being used by this TextActor

Returns:
the text alignment (TXT_Left, TXT_Right, or TXT_Center)

Definition at line 97 of file TextActor.cpp.

void TextActor::SetAlignment ( TextAlignment  newAlignment)

Change the alignment of this TextActor.

Parameters:
newAlignmentthe desigred alignment, as described by the enum

Definition at line 102 of file TextActor.cpp.

const int TextActor::GetLineSpacing ( )

Get the amount of space between each line that this TextActor draws

Returns:
the amount of space (in pixels) that goes between each line

Definition at line 108 of file TextActor.cpp.

void TextActor::SetLineSpacing ( int  newSpacing)

Change the line spacing of this TextActor

Parameters:
newSpacingthe desired amount of space (in pixels) between each line

Definition at line 113 of file TextActor.cpp.

void TextActor::SetPosition ( float  x,
float  y 
) [virtual]

An override of the SetPosition function, since we need to update the screen space drawing coordinates of our text drawing when the TextActor moves in the World.

Parameters:
xthe X coordinate (in GL units) of the TextActor
ythe Y coordinate (in GL units) of the TextActor

Reimplemented from Actor.

Definition at line 119 of file TextActor.cpp.

void TextActor::SetPosition ( const Vector2 position) [virtual]

An override of the SetPosition function, since we need to update the screen space drawing coordinates of our text drawing when the TextActor moves in the World.

Parameters:
positiona Vector2 indicating the X and Y coordinates of the TextActor (in GL units)

Reimplemented from Actor.

Definition at line 131 of file TextActor.cpp.

void TextActor::SetRotation ( float  newRotation) [virtual]

An override of the SetRotation function, since we need to update the screen space drawing coordinates of our text drawing when the TextActor moves in the World.

Parameters:
positiona float indicating the new rotation counter-clockwise around the z-axis (in degrees)

Reimplemented from Actor.

Definition at line 125 of file TextActor.cpp.

void TextActor::ReceiveMessage ( Message message) [virtual]

An implementation of the MessageListener interface, which listens for CameraChange messages and responds appropriately.

See also:
MessageListener
Parameters:
messageThe message getting delivered.

Reimplemented from Actor.

Definition at line 137 of file TextActor.cpp.

const BoundingBox & TextActor::GetBoundingBox ( ) const

Since TextActors use their own methods of drawing, it can be difficult to determine what space they're covering. If you want to do any kind of logic dealing with TextActor overlap, this is the way to get the BoundingBox information.

Returns:
A BoundingBox describing the area covered by the TextActor in GL units (not pixels).

Definition at line 145 of file TextActor.cpp.

virtual const String TextActor::GetClassName ( ) const [inline, virtual]

Used by the SetName function to create a basename for this class. Overridden from Actor::GetClassName.

Returns:
The string "TextActor"

Definition at line 191 of file TextActor.h.


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