The TextManager is a static class which handles Text object addition, removal, and common behavior. The TextManager has many of the same methods (in concept) as the SpriteManager. The TextManager is automatically instantiated by FlatRedBall so you do not need to create an instance yourself.

Text Object

The TextManager provides numerous methods for for working with the Text object. The following sections provide code samples for working with Text-related methods.

Text Addition

Most AddText methods both instantiate a new Text object as well as add it to TextManager for management. The following methods instantiate and add a Text object to the SpriteManager:

Text text = TextManager.AddText("FlatRedBall Rocks!"); // uses default font

Custom BitmapFonts can be used when creating Text objects as well.

BitmapFont bitmapFont = new BitmapFont("textureFile.png", "fontFile.txt", "content manager name");
Text text = TextManager.AddText("Text with custom font", bitmapFont);

For information see the BitmapFont wiki entry.

Adding Text and Layers

Text objects can also be added to Layers.

 // Layers must be created through the SpriteManager
 Layer layer = SpriteManager.AddLayer();

 Text text = TextManager.AddText("I'm on a layer.", layer);

For more information, see the Layer wiki entry and the AddToLayer method.

Text Removal

The RemoveText methods remove Text objects from the engine as well as any two-way AttachableLists (such as PositionedObjectList) that the Text object belong to. For more information, see the RemoveText page.

TextManager Members

[subpages depth="1"]

Last updated