addColor(color, position) → {Phaser.Text}
Set specific colors for certain characters within the Text.
It works by taking a color value, which is a typical HTML string such as #ff0000
or rgb(255,0,0)
and a position.
The position value is the index of the character in the Text string to start applying this color to.
Once set the color remains in use until either another color or the end of the string is encountered.
For example if the Text was Photon Storm
and you did Text.addColor('#ffff00', 6)
it would color in the word Storm
in yellow.
If you wish to change the stroke color see addStrokeColor instead.
Parameters
Name | Type | Description |
---|---|---|
color | string | A canvas fillstyle that will be used on the text eg |
position | number | The index of the character in the string to start applying this color value from. |
Returns
This Text instance.
- Source code: gameobjects/Text.js (Line 829)
Please login to continue.