class flixel.addons.text.FlxBitmapFont extends FlxSprite

Available on all platforms

FlxBitmapFont * * @link http://www.photonstorm.com * @author Richard Davey / Photon Storm * @see Requires FlxMath

Class Fields

static var ALIGN_CENTER:String

Align each line of multi-line text in the center.

static var ALIGN_LEFT:String

Align each line of multi-line text to the left.

static var ALIGN_RIGHT:String

Align each line of multi-line text to the right.

static var TEXT_SET1:String

Text Set 1 = !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~

static var TEXT_SET10:String

Text Set 10 = ABCDEFGHIJKLMNOPQRSTUVWXYZ

static var TEXT_SET11:String

Text Set 11 = ABCDEFGHIJKLMNOPQRSTUVWXYZ.,\"-+!?()':;0123456789

static var TEXT_SET2:String

Text Set 2 = !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ

static var TEXT_SET3:String

Text Set 3 = ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789

static var TEXT_SET4:String

Text Set 4 = ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789

static var TEXT_SET5:String

Text Set 5 = ABCDEFGHIJKLMNOPQRSTUVWXYZ.,/() '!?-*:0123456789

static var TEXT_SET6:String

Text Set 6 = ABCDEFGHIJKLMNOPQRSTUVWXYZ!?:;0123456789\"(),-.'

static var TEXT_SET7:String

Text Set 7 = AGMSY+:4BHNTZ!;5CIOU.?06DJPV,(17EKQW\")28FLRX-'39

static var TEXT_SET8:String

Text Set 8 = 0123456789 .ABCDEFGHIJKLMNOPQRSTUVWXYZ

static var TEXT_SET9:String

Text Set 9 = ABCDEFGHIJKLMNOPQRSTUVWXYZ()-0123456789.:,'\"?!

Instance Fields

var align:String

Alignment of the text when multiLine = true or a fixedWidth is set. Set to FlxBitmapFont.ALIGNLEFT (default), FlxBitmapFont.ALIGNRIGHT or FlxBitmapFont.ALIGN_CENTER.

var autoUpperCase:Bool

Automatically convert any text to upper case. Lots of old bitmap fonts only contain upper-case characters, so the default is true.

var customSpacingX:Int

Adds horizontal spacing between each character of the font, in pixels. Default is 0.

var customSpacingY:Int

Adds vertical spacing between each line of multi-line text, set in pixels. Default is 0.

var multiLine:Bool

If set to true all carriage-returns in text will form new lines (see align). If false the font will only contain one single line of text (the default)

var text:String

Set this value to update the text in this sprite. Carriage returns are automatically stripped * out if multiLine is false. Text is converted to upper case if autoUpperCase is true.

function new(Font:Dynamic, CharacterWidth:Int, CharacterHeight:Int, Chars:String, CharsPerRow:Int, ?SpacingX:Int = 0, ?SpacingY:Int = 0, ?OffsetX:Int = 0, ?OffsetY:Int = 0):Void

Loads 'font' and prepares it for use by future calls to .text * *

Font

The font set graphic class (as defined by your embed) *

CharacterWidth

The width of each character in the font set. *

CharacterHeight

The height of each character in the font set. *

Chars

The characters used in the font set, in display order. You can use the TEXT_SET consts for common font set arrangements. *

CharsPerRow

The number of characters per row in the font set. *

SpacingX

If the characters in the font set have horizontal spacing between them set the required amount here. *

SpacingY

If the characters in the font set have vertical spacing between them set the required amount here *

OffsetX

If the font set doesn't start at the top left of the given image, specify the X coordinate offset here. *

OffsetY

If the font set doesn't start at the top left of the given image, specify the Y coordinate offset here.

function destroy():Void

function getCharacter(Char:String):FlxSprite

Returns a single character from the font set as an FlxSprite. * *

Char

The character you wish to have returned. *

returns

A FlxSprite containing a single character from the font set.

function getCharacterAsBitmapData(Char:String):BitmapData

Returns a single character from the font set as bitmapData * *

Char

The character you wish to have returned. *

returns

bitmapData containing a single character from the font set.

function setFixedWidth(Width:Int, ?LineAlignment:String = 'left'):Void

If you need this FlxSprite to have a fixed width and custom alignment you can set the width here. * If text is wider than the width specified it will be cropped off. * *

Width

Width in pixels of this FlxBitmapFont. Set to zero to disable and re-enable automatic resizing. *

LineAlignment

Align the text within this width. Set to FlxBitmapFont.ALIGNLEFT (default), FlxBitmapFont.ALIGNRIGHT or FlxBitmapFont.ALIGN_CENTER.

function setText(Text:String, ?MultiLines:Bool = false, ?CharacterSpacing:Int = 0, ?LineSpacing:Int = 0, ?LineAlignment:String = 'left', ?AllowLowerCase:Bool = false):Void

A helper function that quickly sets lots of variables at once, and then updates the text. * *

Text

The text of this sprite *

MultiLines

Set to true if you want to support carriage-returns in the text and create a multi-line sprite instead of a single line (default is false). *

CharacterSpacing

To add horizontal spacing between each character specify the amount in pixels (default 0). *

LineSpacing

To add vertical spacing between each line of text, set the amount in pixels (default 0). *

LineAlignment

Align each line of multi-line text. Set to FlxBitmapFont.ALIGNLEFT (default), FlxBitmapFont.ALIGNRIGHT or FlxBitmapFont.ALIGN_CENTER. *

AllowLowerCase

Lots of bitmap font sets only include upper-case characters, if yours needs to support lower case then set this to true.