Text Class
A Text Object will create a line(s) of text to split a line you can use '\n'
Constructor
Text
-
text
-
[style]
Parameters:
-
text
StringThe copy that you would like the text to display
-
[style]
Object optionalThe style parameters
-
[font]
String optionaldefault 'bold 20pt Arial' The style and size of the font
-
[fill='black']
Object optionalA canvas fillstyle that will be used on the text eg 'red', '#00FF00'
-
[align='left']
String optionalAn alignment of the multiline text ('left', 'center' or 'right')
-
[stroke]
String optionalA canvas fillstyle that will be used on the text stroke eg 'blue', '#FCFF00'
-
[strokeThickness=0]
Number optionalA number that represents the thickness of the stroke. Default is 0 (no stroke)
-
[wordWrap=false]
Boolean optionalIndicates if word wrap should be used
-
[wordWrapWidth=100]
Number optionalThe width at which text will wrap
-
Item Index
Methods
destroy
-
destroyTexture
Destroys this text object
Parameters:
-
destroyTexture
Boolean
setStyle
-
[style]
-
[style.font='bold
Set the style of the text
Parameters:
-
[style]
Object optionalThe style parameters
-
[fill='black']
Object optionalA canvas fillstyle that will be used on the text eg 'red', '#00FF00'
-
[align='left']
String optionalAn alignment of the multiline text ('left', 'center' or 'right')
-
[stroke='black']
String optionalA canvas fillstyle that will be used on the text stroke eg 'blue', '#FCFF00'
-
[strokeThickness=0]
Number optionalA number that represents the thickness of the stroke. Default is 0 (no stroke)
-
[wordWrap=false]
Boolean optionalIndicates if word wrap should be used
-
[wordWrapWidth=100]
Number optionalThe width at which text will wrap
-
-
[style.font='bold
String20pt Arial'] The style and size of the font
setText
-
text
Set the copy for the text object. To split a line you can use '\n'
Parameters:
-
text
StringThe copy that you would like the text to display
updateText
()
private
Renders text
updateTexture
()
private
Updates texture size based on canvas size
updateTransform
()
private
Updates the transfor of this object
wordWrap
-
text
Applies newlines to a string to have it optimally fit into the horizontal bounds set by the Text object's wordWrapWidth property.
Parameters:
-
text
String