class flixel.text.FlxText extends FlxSprite

Available on all platforms

Extends FlxSprite to support rendering text. Can tint, fade, rotate and scale just like a sprite. Doesn't really animate * though, as far as I know. Also does nice pixel-perfect centering on pixel fonts as long as they are only one liners.

Class Fields

static var BORDER_NONE:Int

static var BORDER_OUTLINE:Int

Outline on all 8 sides

static var BORDER_OUTLINE_FAST:Int

Outline, optimized using only 4 draw calls. (Might not work for narrow and/or 1-pixel fonts)

static var BORDER_SHADOW:Int

A simple shadow to the lower-right

Instance Fields

var alignment:String

The alignment of the font ("left", "right", or "center").

var autoSize:Bool

Whether the fieldWidth should be determined automatically. Requires wordWrap to be false.

var bold:Bool

Whether to use bold text or not (false by default).

var borderColor:Int

The color of the border in 0xRRGGBB format

var borderQuality:Float

How many iterations do use when drawing the border. 0: only 1 iteration, 1: one iteration for every pixel in borderSize * A value of 1 will have the best quality for large border sizes, but might reduce performance when changing text. * NOTE: If the borderSize is 1, borderQuality of 0 or 1 will have the exact same effect (and performance).

var borderSize:Float

The size of the border, in pixels.

var borderStyle:Int

Use a border style like FlxText.SHADOW or FlxText.OUTLINE

var embedded:Bool

Whether this text field uses an embedded font (by default) or not. * Read-only - use systemFont to specify a system font to use, which then automatically sets this to false.

var fieldWidth:Float

The width of the TextField object used for bitmap generation for this FlxText object. * Use it when you want to change the visible width of text. Enables autoSize if <= 0.

var font:String

The font used for this text (assuming that it's using embedded font).

var italic:Bool

Whether to use italic text or not (false by default). It only works in Flash.

var shadowOffset:FlxPoint

Offset that is applied to the shadow border style, if active. * x and y are multiplied by borderSize. Default is (1, 1), or lower-right corner.

var size:Float

The size of the text being displayed.

var systemFont:String

The system font for this text (not embedded). Setting this sets embedded to false. * Passing an invalid font name (like "" or null) causes a default font to be used.

var text:String

The text being displayed.

var textField:TextField

Internal reference to a Flash TextField object.

var wordWrap:Bool

Whether to use word wrapping and multiline or not (true by default).

function new(?X:Float = 0, ?Y:Float = 0, ?FieldWidth:Float = 0, ?Text:String = null, ?Size:Int = 8, ?EmbeddedFont:Bool = true):Void

Creates a new FlxText object at the specified position. * *

X

The X position of the text. *

Y

The Y position of the text. *

FieldWidth

The width of the text object. Enables autoSize if <= 0. (height is determined automatically). *

Text

The actual text you would like to display initially. *

Size

The font size for this text object. *

EmbeddedFont

Whether this text field uses embedded fonts or not.

function addFilter(filter:BitmapFilter, ?widthInc:Int = 0, ?heightInc:Int = 0):Void

function addFormat(Format:FlxTextFormat, ?Start:Int = -1, ?End:Int = -1):Void

Adds another format to this FlxText * *

Format

The format to be added. *

Start

(Default = -1) The start index of the string where the format will be applied. If greater than -1, this value will override the format.start value. *

End

(Default = -1) The end index of the string where the format will be applied. If greater than -1, this value will override the format.start value.

function clearFilters():Void

function clearFormats():Void

Clears all the formats applied.

function destroy():Void

Clean up memory.

function removeFilter(filter:BitmapFilter):Void

function removeFormat(Format:FlxTextFormat):Void

Removes a specific FlxTextFormat from this text.

function setBorderStyle(Style:Int, ?Color:Int = 0, ?Size:Float = 1, ?Quality:Float = 1):Void

Set border's style (shadow, outline, etc), color, and size all in one go! * *

Style

outline style - FlxText.NONE, SHADOW, OUTLINE, OUTLINE_FAST *

Color

outline color in flash 0xRRGGBB format *

Size

outline size in pixels *

Quality

outline quality - # of iterations to use when drawing. 0:just 1, 1:equal number to BorderSize

function setFormat(?Font:String = null, ?Size:Float = 8, ?Color:Int = 16777215, ?Alignment:String = null, ?BorderStyle:Int = 0, ?BorderColor:Int = 0, ?Embedded:Bool = true):FlxText

You can use this if you have a lot of text parameters * to set instead of the individual properties. * *

Font

The name of the font face for the text display. *

Size

The size of the font (in pixels essentially). *

Color

The color of the text in traditional flash 0xRRGGBB format. *

Alignment

A string representing the desired alignment ("left,"right" or "center"). *

BorderStyle

FlxText.NONE, SHADOW, OUTLINE, or OUTLINE_FAST (use setBorderFormat *

BorderColor

Int, color for the border, 0xRRGGBB format *

EmbeddedFont

Whether this text field uses embedded fonts or not *

returns

This FlxText instance (nice for chaining stuff together, if you're into that).