Angel 3.2
A 2D Game Prototyping Engine
Classes | Public Member Functions | List of all members
TextActor Class Reference

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

#include <TextActor.h>

+ Inheritance diagram for TextActor:

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
 
- Public Member Functions inherited from Actor
 Actor ()
 
virtual ~Actor ()
 
void SetSize (float x, float y=-1.f)
 
void SetSize (const Vector2 &newSize)
 
const Vector2GetSize () const
 
const BoundingBox GetBoundingBox () const
 
const Vector2GetPosition () const
 
const float GetRotation () const
 
void SetColor (float r, float g, float b, float a=1.0f)
 
void SetColor (const Color &color)
 
const ColorGetColor () const
 
void SetAlpha (float newAlpha)
 
const float GetAlpha () const
 
virtual void SetDrawShape (actorDrawShape drawShape)
 
const actorDrawShapeGetDrawShape () const
 
void UseDisplayList (int listIndex)
 
void MoveTo (const Vector2 &newPosition, float duration, bool smooth=false, String onCompletionMessage="")
 
void RotateTo (float newRotation, float duration, bool smooth=false, String onCompletionMessage="")
 
void ChangeColorTo (const Color &newColor, float duration, bool smooth=false, String onCompletionMessage="")
 
void ChangeSizeTo (const Vector2 &newSize, float duration, bool smooth=false, String onCompletionMessage="")
 
void ChangeSizeTo (float newSize, float duration, bool smooth=false, String onCompletionMessage="")
 
int GetSpriteTexture (int frame=0) const
 
bool SetSprite (const String &filename, int frame=0, GLint clampmode=GL_CLAMP, GLint filtermode=GL_LINEAR, bool optional=false)
 
void ClearSpriteInfo ()
 
void LoadSpriteFrames (const String &firstFilename, GLint clampmode=GL_CLAMP, GLint filtermode=GL_LINEAR)
 
void PlaySpriteAnimation (float delay, spriteAnimationType animType=SAT_Loop, int startFrame=-1, int endFrame=-1, const char *animName=NULL)
 
void SetSpriteFrame (int frame)
 
int GetSpriteFrame () const
 
const bool IsSpriteAnimPlaying () const
 
virtual void AnimCallback (String animName)
 
void SetUVs (const Vector2 &lowleft, const Vector2 &upright)
 
void GetUVs (Vector2 &lowleft, Vector2 &upright) const
 
const bool IsTagged (const String &tag)
 
void Tag (const String &newTag)
 
void Untag (const String &oldTag)
 
const StringSet & GetTags () const
 
const String & SetName (String newName)
 
const String & GetName () const
 
void SetLayer (int layerIndex)
 
void SetLayer (const String &layerName)
 
virtual void Update (float dt)
 
virtual void LevelUnloaded ()
 
ActorGetSelf ()
 
- Public Member Functions inherited from Renderable
 Renderable ()
 
virtual ~Renderable ()
 
void Destroy ()
 
bool IsDestroyed ()
 
int GetLayer ()
 

Additional Inherited Members

- Static Public Member Functions inherited from Actor
static Actor *const GetNamed (const String &nameLookup)
 
static ActorCreate (const String &archetype)
 
static void SetScriptCreatedActor (Actor *a)
 
- Protected Member Functions inherited from Renderable
virtual void PreDestroy ()
 
- Protected Attributes inherited from Actor
Vector2 _size
 
Vector2 _position
 
Color _color
 
float _rotation
 
float _UV [8]
 
actorDrawShape _drawShape
 
int _spriteCurrentFrame
 
int _spriteNumFrames
 
float _spriteFrameDelay
 
float _spriteCurrentFrameDelay
 
int _spriteTextureReferences [MAX_SPRITE_FRAMES]
 
spriteAnimationType _spriteAnimType
 
int _spriteAnimStartFrame
 
int _spriteAnimEndFrame
 
int _spriteAnimDirection
 
int _displayListIndex
 
StringSet _tags
 
String _name
 
String _currentAnimName
 
- Static Protected Attributes inherited from Actor
static const float _squareVertices []
 
static float _circleVertices []
 
static float _circleTextureCoords []
 
static std::map< String, Actor * > _nameList
 
static Actor_scriptCreatedActor = NULL
 

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
inlinevirtual

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

Returns
The string "TextActor"

Reimplemented from Actor.

Definition at line 191 of file TextActor.h.


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