setStyle(style, update) → {Phaser.Text}
Set the style of the text by passing a single style object to it.
Parameters
Name | Type | Argument | Default | Description |
---|
style | object | <optional>
| |
The style properties to be set on the Text. Properties Name | Type | Argument | Default | Description |
---|
font | string | <optional>
| 'bold 20pt Arial' | The style and size of the font. | fontStyle | string | <optional>
| (from font) | The style of the font (eg. 'italic'): overrides the value in style.font . | fontVariant | string | <optional>
| (from font) | The variant of the font (eg. 'small-caps'): overrides the value in style.font . | fontWeight | string | <optional>
| (from font) | The weight of the font (eg. 'bold'): overrides the value in style.font . | fontSize | string | number | <optional>
| (from font) | The size of the font (eg. 32 or '32px'): overrides the value in style.font . | backgroundColor | string | <optional>
| null | A canvas fillstyle that will be used as the background for the whole Text object. Set to null to disable. | fill | string | <optional>
| 'black' | A canvas fillstyle that will be used on the text eg 'red', '#00FF00'. | align | string | <optional>
| 'left' | Horizontal alignment of each line in multiline text. Can be: 'left', 'center' or 'right'. Does not affect single lines of text (see textBounds and boundsAlignH for that). | boundsAlignH | string | <optional>
| 'left' | Horizontal alignment of the text within the textBounds . Can be: 'left', 'center' or 'right'. | boundsAlignV | string | <optional>
| 'top' | Vertical alignment of the text within the textBounds . Can be: 'top', 'middle' or 'bottom'. | stroke | string | <optional>
| 'black' | A canvas stroke style that will be used on the text stroke eg 'blue', '#FCFF00'. | strokeThickness | number | <optional>
| 0 | A number that represents the thickness of the stroke. Default is 0 (no stroke). | wordWrap | boolean | <optional>
| false | Indicates if word wrap should be used. | wordWrapWidth | number | <optional>
| 100 | The width in pixels at which text will wrap. | maxLines | number | <optional>
| 0 | The maximum number of lines to be shown for wrapped text. | tabs | number | array | <optional>
| 0 | The size (in pixels) of the tabs, for when text includes tab characters. 0 disables. Can be an array of varying tab sizes, one per tab stop. |
|
update | boolean | <optional>
| false | Immediately update the Text object after setting the new style? Or wait for the next frame. |
Returns
- Source code: gameobjects/Text.js (Line 267)
Please login to continue.