Fork me on GitHub
View source

package com.haxepunk.graphics

class BitmapText


extends Graphic

An object for drawing text using a bitmap font.


Available since:

2.5.0

Constructor

View source

new (text : String, x : Float = 0, y : Float = 0, width : Float = 0, height : Float = 0, options : BitmapTextOptions) : Void

BitmapText constructor.


Parameters:
text   

Text to display.

x   

X offset.

y   

Y offset.

width   

Image width (leave as 0 to size to the starting text string).

height   

Image height (leave as 0 to size to the starting text string).

options   

An object containing optional parameters contained in BitmapTextOptions font Name of the font asset (.fnt or .png). size Font size. format Font format (BitmapFontFormat.XML or BitmapFontFormat.XNA). wordWrap Automatic word wrapping. color Text color. align Alignment ("left", "center" or "right"). (Currently ignored.) resizable If the text field can automatically resize if its contents grow. (Currently ignored.) leading Vertical space between lines. (Currently ignored.) richText If the text field uses a rich text string. (Currently ignored.)

Variables

alpha : Float

autoHeight : Bool

Whether or not to automatically figure out the height and width of the text.

default value

False.

autoWidth : Bool

charSpacing : Int

color : Int

height : Float

lineSpacing : Int

lines : Array<String>

scale : Float

scaleX : Float

scaleY : Float

size : Int

smooth : Bool

Default value: false if HXP.stage.quality is LOW, true otherwise.

text : String

textHeight : Int

textWidth : Int

width : Float

wrap : Bool

Functions

View source

computeTextSize () : Void

Run through the render loop without actually drawing anything. This will compute the textWidth and textHeight attributes.

View source

updateBuffer (oldLines : Array<String>) : Void

Update the drawing buffer on software rendering mode. For efficiency, if any lines were unchanged from previously rendered text, they will not be re-drawn.

View source

wordWrap () : Void

Automatically wraps text by figuring out how many words can fit on a single line, and splitting the remainder onto a new line.