Scope: static
Source: src/gameobjects/components/Tint.js#L7
Since: 3.0.0
Static functions
isTinted
isTinted: boolean
Description:
Does this Game Object have a tint applied?
It checks to see if the 4 tint properties are set to the value 0xffffff
and that the tintFill
property is false
. This indicates that a Game Object isn't tinted.
Tags:
- webglOnly
Source: src/gameobjects/components/Tint.js#L205
Since: 3.11.0
tint
tint: number
Description:
The tint value being applied to the whole of the Game Object.
Return tintTopLeft
when read this tint property.
Tags:
- webglOnly
Source: src/gameobjects/components/Tint.js#L183
Since: 3.0.0
tintBottomLeft
tintBottomLeft: number
Description:
The tint value being applied to the bottom-left vertice of the Game Object. This value is interpolated from the corner to the center of the Game Object. The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple.
Source: src/gameobjects/components/Tint.js#L42
Since: 3.0.0
tintBottomRight
tintBottomRight: number
Description:
The tint value being applied to the bottom-right vertice of the Game Object. This value is interpolated from the corner to the center of the Game Object. The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple.
Source: src/gameobjects/components/Tint.js#L54
Since: 3.0.0
tintFill
tintFill: boolean
Description:
The tint fill mode.
false
= An additive tint (the default), where vertices colors are blended with the texture.
true
= A fill tint, where the vertices colors replace the texture, but respects texture alpha.
Source: src/gameobjects/components/Tint.js#L66
Since: 3.11.0
tintTopLeft
tintTopLeft: number
Description:
The tint value being applied to the top-left vertice of the Game Object. This value is interpolated from the corner to the center of the Game Object. The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple.
Source: src/gameobjects/components/Tint.js#L18
Since: 3.0.0
tintTopRight
tintTopRight: number
Description:
The tint value being applied to the top-right vertice of the Game Object. This value is interpolated from the corner to the center of the Game Object. The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple.
Source: src/gameobjects/components/Tint.js#L30
Since: 3.0.0
Static functions
clearTint
<instance> clearTint()
Description:
Clears all tint values associated with this Game Object.
Immediately sets the color values back to 0xffffff and the tint type to 'additive', which results in no visible change to the texture.
Tags:
- webglOnly
Returns: Phaser.GameObjects.Components.Tint - This Game Object instance.
Source: src/gameobjects/components/Tint.js#L79
Since: 3.0.0
setTint
<instance> setTint([topLeft], [topRight], [bottomLeft], [bottomRight])
Description:
Sets an additive tint on this Game Object.
The tint works by taking the pixel color values from the Game Objects texture, and then multiplying it by the color value of the tint. You can provide either one color value, in which case the whole Game Object will be tinted in that color. Or you can provide a color per corner. The colors are blended together across the extent of the Game Object.
To modify the tint color once set, either call this method again with new values or use the
tint
property to set all colors at once. Or, use the properties tintTopLeft
, tintTopRight,
tintBottomLeftand
tintBottomRight` to set the corner color values independently.
To remove a tint call clearTint
.
To swap this from being an additive tint to a fill based tint set the property tintFill
to true
.
Tags:
- webglOnly
Parameters:
name | type | optional | default | description |
---|---|---|---|---|
topLeft | number | Yes | "0xffffff" | The tint being applied to the top-left of the Game Object. If no other values are given this value is applied evenly, tinting the whole Game Object. |
topRight | number | Yes | The tint being applied to the top-right of the Game Object. | |
bottomLeft | number | Yes | The tint being applied to the bottom-left of the Game Object. | |
bottomRight | number | Yes | The tint being applied to the bottom-right of the Game Object. |
Returns: Phaser.GameObjects.Components.Tint - This Game Object instance.
Source: src/gameobjects/components/Tint.js#L98
Since: 3.0.0
setTintFill
<instance> setTintFill([topLeft], [topRight], [bottomLeft], [bottomRight])
Description:
Sets a fill-based tint on this Game Object.
Unlike an additive tint, a fill-tint literally replaces the pixel colors from the texture with those in the tint. You can use this for effects such as making a player flash 'white' if hit by something. You can provide either one color value, in which case the whole Game Object will be rendered in that color. Or you can provide a color per corner. The colors are blended together across the extent of the Game Object.
To modify the tint color once set, either call this method again with new values or use the
tint
property to set all colors at once. Or, use the properties tintTopLeft
, tintTopRight,
tintBottomLeftand
tintBottomRight` to set the corner color values independently.
To remove a tint call clearTint
.
To swap this from being a fill-tint to an additive tint set the property tintFill
to false
.
Tags:
- webglOnly
Parameters:
name | type | optional | default | description |
---|---|---|---|---|
topLeft | number | Yes | "0xffffff" | The tint being applied to the top-left of the Game Object. If not other values are given this value is applied evenly, tinting the whole Game Object. |
topRight | number | Yes | The tint being applied to the top-right of the Game Object. | |
bottomLeft | number | Yes | The tint being applied to the bottom-left of the Game Object. | |
bottomRight | number | Yes | The tint being applied to the bottom-right of the Game Object. |
Returns: Phaser.GameObjects.Components.Tint - This Game Object instance.
Source: src/gameobjects/components/Tint.js#L146
Since: 3.11.0