[ Home ]

Library Documentation (v 0.13.0)

Text

For displaying text on screen.
Text.font:String
Set the font to a font from data/fonts/
Text.size:Float
Change the size of the font. For ttf fonts, sizes are given in point format - e.g. 16, 32, 48, etc. For bitmap fonts, sizes are given in multiple scales - 1 is normal, 2 is double size, 3 is triple, etc.
Text.setfont(font:String, size:Float, ?usehighres:Bool)
Change the font and font size at the same time. (Can optionally set usehighres to increase the texture size of the font, which may increase its legibility in some cases.)
Text.display(x:Float, y:Float, text:String, color:Int = 0xFFFFFF, alpha:Float = 1.0)
Draws text on the screen at a given point.
Text.input(x:Float, y:Float, color:Int = Col.WHITE):Bool
Displays a prompt on screen where you can type a string. Returns true when the user presses Key.ENTER.
Text.inputresult:String
A string containing the most recent value of Text.input() after Key.ENTER has been pressed.
Text.inputbuffer:String
Advanced! For if you want to do something more complicated than Text.input() allows. Text.inputbuffer contains a string with all the characters that the player has typed in, including newline characters.
Text.inputmaxlength:Int
Sets maximum response length of Text.input().
Text.wordwrap:Int
Sets the word-wrap width for Text.display() commands.
Text.rotation(angle:Float, pivotx:Int = 0, pivoty:Int = 0)
Sets the rotation of Text.display() commands. (pivotx, pivoty) can be a point, or it can use the constants Text.LEFT, Text.CENTER or Text.RIGHT.
Text.align:Int
Sets the alignment for Text.display() commands. Set to either Text.LEFT, Text.CENTER or Text.RIGHT.
Text.width(text:String):Float
Returns the width in pixels of the given string.
Text.height(text:String):Float
Returns the height in pixels of the given string. If text is left blank, it returns the height in pixels of any line of text in the current font.
Text.CENTER
A constant used for text alignment/rotation in Text.align and Text.rotation().
Text.LEFT
A constant used for text alignment/rotation in Text.align and Text.rotation().
Text.RIGHT
A constant used for text alignment/rotation in Text.align and Text.rotation().
Text.TOP
A constant used for text alignment/rotation in Text.align and Text.rotation().
Text.BOTTOM
A constant used for text alignment/rotation in Text.align and Text.rotation().