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