Text
Creates a Text
Renders a line or multiple lines of text to the canvas.
The primary advantage of this class over BitmapText is that you have great control over the style of the text, which you can change at runtime.
The primary disadvantages is that each piece of text has it’s own texture, which can use more memory. When text changes, this texture has to be re-generated and re-uploaded to the GPU, taking up time.
To split a line you can use \n
in your text string, or, on the style prop, change its wordWrap
property to true and and give the wordWrapWidth
property a value.
API
Text Attributes
Name | Type | Default | Description |
---|---|---|---|
text | string | undefined | The text to display. |
style | object | undefined | The style parameters. |
anchor |
| 0 | The anchor sets the origin point of the text. |
anchor-x | number | 0 | The x anchor sets the origin point of the text. |
anchor-y | number | 0 | The y anchor sets the origin point of the text. |
more props in Container Props and PIXI.Text
Text Events
Name | Type | Description |
---|---|---|
render | function | custom render function |
more events in Container Events