![]() |
Angel
A 2D Game Prototyping Engine
|
An Actor for displaying text on the screen. More...
#include <TextActor.h>
Inheritance diagram for TextActor: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 BoundingBox & | GetBoundingBox () const |
| virtual const String | GetClassName () const |
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.
| 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.
| fontNickname | the 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. |
| displayString | the actual text to be displayed |
| align | the desired alignment of the text |
| lineSpacing | the amount of space (in pixels) between each line of text |
Definition at line 40 of file TextActor.cpp.
| 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
Definition at line 64 of file TextActor.cpp.
| void TextActor::SetFont | ( | const String & | newFont | ) |
Change the font used in drawing this TextActor.
| newFont | the 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.
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).
| newString | the 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
Definition at line 97 of file TextActor.cpp.
| void TextActor::SetAlignment | ( | TextAlignment | newAlignment | ) |
Change the alignment of this TextActor.
| newAlignment | the 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
Definition at line 108 of file TextActor.cpp.
| void TextActor::SetLineSpacing | ( | int | newSpacing | ) |
Change the line spacing of this TextActor
| newSpacing | the 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.
| x | the X coordinate (in GL units) of the TextActor |
| y | the 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.
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.
| position | a 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.
| message | The 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.
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.
Definition at line 191 of file TextActor.h.


1.7.5.1