FlatRedBall TextHelper

Tagged:

This library adds some features to the FRB Text class:

Namespace: de.invidit.XNA
TargetFramework: .NET Framework 4
XNA Version: XNA4
Tested with FRB for XNAPC only.

The TextHelper adds various classes for the work with the FRBs Text class.
Just add de.invidit.XNA to your source file and you are able to use the new classes.

Classes included in this library:

GrowingText
This class provides an animated growing text for Flat Red Ball.

Public Member Functions
GrowingText (string displayText, string fontName, Color color, float scale, Vector3 position, float growScale, float growSpeed=5)
Constructor.

void Destroy ()
Removes Text objects from Managers and sets them to null.

void SetHorizontalAlignment (HorizontalAlignment alignment)
Sets the horizontal alignment of the text.

void SetVerticalAlignment (VerticalAlignment alignment)
Sets the vertical alignment of the text.

void Update ()
Updates the texts animation. Needs to be called each frame.

Properties
Color Color [get, set]
The color of the instance.

string DisplayText [get, set]
Gets or sets the string that the Text object is to display.

Vector3 Position [get, set]
The absolute world position of the instance.

Vector3 Velocity [get, set]
The velocity of the instance.

JumpingText
This class provides an animated jumping text for Flat Red Ball.
Public Member Functions
JumpingText (string displayText, string fontName, Color color, float scale, Vector3 position, Vector2 jumpDistance, float jumpSpeed=5)
Constructor.

void Destroy ()
Removes Text objects from Managers and sets them to null.

void SetHorizontalAlignment (HorizontalAlignment alignment)
Sets the horizontal alignment of the text.

void SetJumpDistance (float x, float y)
Sets the x and y distance of the jumping text. These values might be negative.

void SetVerticalAlignment (VerticalAlignment alignment)
Sets the vertical alignment of the text.

void Update ()
Updates the texts animation. Needs to be called each frame.

Properties
Color Color [get, set]
The color of the instance.

string DisplayText [get, set]
Gets or sets the string that the Text object is to display.

Vector3 Position [get, set]
The absolute world position of the instance.

Vector3 Velocity [get, set]
The velocity of the instance.

ShadowedText
This class provides a shadowed text for Flat Red Ball.
Public Member Functions
ShadowedText (string displayText, string fontName, Color color, Color shadowColor, float scale, Vector3 position)
Constructor.

void SetShadowDistance (float x, float y)
Sets the x and y distance of the shadow to the text. These values might be negative.

void SetVerticalAlignment (VerticalAlignment alignment)
Sets the vertical alignment of the text.

void SetHorizontalAlignment (HorizontalAlignment alignment)
Sets the horizontal alignment of the text.

void Destroy ()
Removes Text objects from Managers and sets them to null.

Properties
string DisplayText [get, set]
Gets or sets the string that the Text object is to display.

Vector3 Position [get, set]
The absolute world position of the instance.

Color Color [get, set]
The color of the instance.

Vector3 Velocity [get, set]
The velocity of the instance.

Vector3 Acceleration [get, set]
The acceleration of the instance.

TextHelper
This class provides helper methods for text related objects.
Static Public Member Functions

static Color GetTextColor (Text text)
Returns the color of the specified text.

static Text CreateText (string displayText, string fontName, Color color, float scale, Vector3 position)
Creates a FlatRedBall text and adds it to the TextManager.

static void SetTextColor (ref Text text, Color color)
Sets the color of teh specified text.

static string BreakTextIntoLines (string text, int maximumCharactersPerLine, int maximumLines)
Adds newline characters to a string so that it fits within a certain size.

static string BreakTextIntoLines (string text, int maximumCharactersPerLine)
Adds new-line characters to a string to make it fit.

static string[] BreakTextIntoLines (int lineLength, string text, SpriteFont font)
Splits the text into single lines in an array by the specified parameters.

static List< string > BreakTextIntoList (string text, SpriteFont font, int lineLength)
Break text up into separate lines to make it fit.

static BitmapFont LoadFont (string fontName)
Returns a BitmapFont loaded from the project. The font must be built up of an .png-file with the textures and a .fnt-file containing the texture description. Use the BMFont tool to create such a font. The fonts must be placed in the folder "Content\Fonts".

See included doc comments for more details.
The uploaded file also contains a sample project. You just need to add the FRB library (the project was created using FRB 07/2011).

Product File: 
Syndicate content