TextManager

Intelligently draws text and captions.

About

This is a global object that can always be accessed.

Text is always drawn over all tiles/entities.  (will not be obscured)

Usage

GetTextManager:Add("Hmm?", this);
Summary
TextManagerIntelligently draws text and captions.
Member Functions
Add
AddCustom
AddCustomScreen
Related Constants
C_FONT_CONSTANTSCan be used as fontID’s with functions such as TextManager::AddCustom.
C_FONT_SMALLA very small font.
C_FONT_DEFAULTA medium sized font.

Member Functions

Add

number Add(string msg, Entity ent)

This function causes text to pop up over an entity, wait an appropriate amount of time (depends on text length) and then fade out.

Text is vertically stacked (newest on the bottom) if an Entity has multiple lines showing.

Text is depth sorted by age.  (newer text is readable over older text)

If an Entity is deleted, any associated text is automatically deleted as well.

The color of text can be adjusted with Entity::SetDefaultTalkColor.

Parameters

msgThe line of text this Entity should say.  Automatically text wrapped if needed.
entThe Entity object that should “say” this line of text.

Returns

How many milliseconds the text will be displayed, sometimes useful to know when timing things.

AddCustom

nil AddCustom(string msg, Entity ent, Vector2 vPos, Vector2 vMovement, Color color,
number timeToShowMS, number fontID)

This is like a turbo-powered version of Add that gives you many more options.

An important difference is the text doesn’t follow around the Entity like with Add, it stays in the position sent and optionally applies movement to it.

If an Entity is deleted, any associated text is automatically deleted as well.

Usage

//pretend we got hit for 5 damage.  Let's make a red 5 appear and float up, a common RPG damage effect.
GetTextManager:AddCustom("5", this, this:GetPos(), Vector2(0, -0.3), Color(200,0,0,255), 2000, C_FONT_DEFAULT);

Parameters

msgThe line of text that should be displayed.  Automatically text wrapped if needed.
entThe Entity object that should “say” this line of text.
vPosA Vector2 object containing the world coordinates of where the text should be displayed.  (will be centered around it)
vMovementA Vector2 describing a direction and amount of movement to apply to the text.  Send 0,0 for no movement.
ColorA Color object describing the color of the text.
timeToShowMSHow many milliseconds this text should remain.
fontIDA valid fontID or one of the C_FONT_CONSTANTS.

AddCustomScreen

nil AddCustomScreen(string msg, Vector2 vPos, Vector2 vMovement, Color color,
number timeToShowMS, number fontID)

This is similar to AddCustom with some important differences:

  • vPos is set in screen coordinates.  (0,0 would be the upper left) The text stays on the screen at all times and is not affected by camera movement or changing Maps.
  • It is not associated with an Entity

This function is used to show tips and help in the examples.

Parameters

msgThe line of text that should be displayed.  Automatically text wrapped if needed.
vPosA Vector2 object containing the screen coordinates of where the text should be displayed.  (will be centered around it)
vMovementA Vector2 describing a direction and amount of movement to apply to the text.  Send 0,0 for no movement.
ColorA Color object describing the color of the text.
timeToShowMSHow many milliseconds this text should remain.
fontIDA valid fontID or one of the C_FONT_CONSTANTS.

Related Constants

Summary
C_FONT_CONSTANTSCan be used as fontID’s with functions such as TextManager::AddCustom.
C_FONT_SMALLA very small font.
C_FONT_DEFAULTA medium sized font.

C_FONT_CONSTANTS

Can be used as fontID’s with functions such as TextManager::AddCustom.

C_FONT_SMALL

A very small font.

C_FONT_DEFAULT

A medium sized font.

The Entity object.
The Vector2 object.
The color object stores R G B A color information.
Can be used as fontID’s with functions such as TextManager::AddCustom.
A map is a single area that can be any size and contain any amount of tiles, including Entities and TilePic’s.