class flixel.text.FlxText extends FlxSprite
Available on all platforms
Sub classes | ||||||||||
![]() | FlxTypeText, FlxInputText, FlxUIText, FlxTextField |
|
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_OUTLINE_FAST:Int
Outline, optimized using only 4 draw calls. (Might not work for narrow and/or 1-pixel fonts)
Instance Fields
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).
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 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 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.
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 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 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). |