44 * @license {@link https://opensource.org/licenses/MIT|MIT License }
55 */
66
7- var GetColorFromValue = require ( '../../display/color/GetColorFromValue' ) ;
8-
97/**
108 * Provides methods used for setting the tint of a Game Object.
119 * Should be applied as a mixin and not used directly.
@@ -18,62 +16,58 @@ var GetColorFromValue = require('../../display/color/GetColorFromValue');
1816var Tint = {
1917
2018 /**
21- * Private internal value. Holds the top-left tint value.
19+ * The tint value being applied to the top-left vertice of the Game Object.
20+ * This value is interpolated from the corner to the center of the Game Object.
21+ * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple.
2222 *
23- * @name Phaser.GameObjects.Components.Tint#_tintTL
23+ * @name Phaser.GameObjects.Components.Tint#tintTopLeft
2424 * @type {number }
25- * @private
26- * @default 16777215
25+ * @default 0xffffff
2726 * @since 3.0.0
2827 */
29- _tintTL : 16777215 ,
28+ tintTopLeft : 0xffffff ,
3029
3130 /**
32- * Private internal value. Holds the top-right tint value.
31+ * The tint value being applied to the top-right vertice of the Game Object.
32+ * This value is interpolated from the corner to the center of the Game Object.
33+ * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple.
3334 *
34- * @name Phaser.GameObjects.Components.Tint#_tintTR
35+ * @name Phaser.GameObjects.Components.Tint#tintTopRight
3536 * @type {number }
36- * @private
37- * @default 16777215
37+ * @default 0xffffff
3838 * @since 3.0.0
3939 */
40- _tintTR : 16777215 ,
40+ tintTopRight : 0xffffff ,
4141
4242 /**
43- * Private internal value. Holds the bottom-left tint value.
43+ * The tint value being applied to the bottom-left vertice of the Game Object.
44+ * This value is interpolated from the corner to the center of the Game Object.
45+ * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple.
4446 *
45- * @name Phaser.GameObjects.Components.Tint#_tintBL
47+ * @name Phaser.GameObjects.Components.Tint#tintBottomLeft
4648 * @type {number }
47- * @private
48- * @default 16777215
49+ * @default 0xffffff
4950 * @since 3.0.0
5051 */
51- _tintBL : 16777215 ,
52+ tintBottomLeft : 0xffffff ,
5253
5354 /**
54- * Private internal value. Holds the bottom-right tint value.
55+ * The tint value being applied to the bottom-right vertice of the Game Object.
56+ * This value is interpolated from the corner to the center of the Game Object.
57+ * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple.
5558 *
56- * @name Phaser.GameObjects.Components.Tint#_tintBR
59+ * @name Phaser.GameObjects.Components.Tint#tintBottomRight
5760 * @type {number }
58- * @private
59- * @default 16777215
61+ * @default 0xffffff
6062 * @since 3.0.0
6163 */
62- _tintBR : 16777215 ,
64+ tintBottomRight : 0xffffff ,
6365
6466 /**
65- * Private internal value. Holds if the Game Object is tinted or not .
67+ * The tint fill mode .
6668 *
67- * @name Phaser.GameObjects.Components.Tint#_isTinted
68- * @type {boolean }
69- * @private
70- * @default false
71- * @since 3.11.0
72- */
73- _isTinted : false ,
74-
75- /**
76- * Fill or additive?
69+ * `false` = An additive tint (the default), where vertices colors are blended with the texture.
70+ * `true` = A fill tint, where the vertices colors replace the texture, but respects texture alpha.
7771 *
7872 * @name Phaser.GameObjects.Components.Tint#tintFill
7973 * @type {boolean }
@@ -98,8 +92,6 @@ var Tint = {
9892 {
9993 this . setTint ( 0xffffff ) ;
10094
101- this . _isTinted = false ;
102-
10395 return this ;
10496 } ,
10597
@@ -141,12 +133,10 @@ var Tint = {
141133 bottomRight = topLeft ;
142134 }
143135
144- this . _tintTL = GetColorFromValue ( topLeft ) ;
145- this . _tintTR = GetColorFromValue ( topRight ) ;
146- this . _tintBL = GetColorFromValue ( bottomLeft ) ;
147- this . _tintBR = GetColorFromValue ( bottomRight ) ;
148-
149- this . _isTinted = true ;
136+ this . tintTopLeft = topLeft ;
137+ this . tintTopRight = topRight ;
138+ this . tintBottomLeft = bottomLeft ;
139+ this . tintBottomRight = bottomRight ;
150140
151141 this . tintFill = false ;
152142
@@ -190,102 +180,6 @@ var Tint = {
190180 return this ;
191181 } ,
192182
193- /**
194- * The tint value being applied to the top-left of the Game Object.
195- * This value is interpolated from the corner to the center of the Game Object.
196- *
197- * @name Phaser.GameObjects.Components.Tint#tintTopLeft
198- * @type {integer }
199- * @webglOnly
200- * @since 3.0.0
201- */
202- tintTopLeft : {
203-
204- get : function ( )
205- {
206- return this . _tintTL ;
207- } ,
208-
209- set : function ( value )
210- {
211- this . _tintTL = GetColorFromValue ( value ) ;
212- this . _isTinted = true ;
213- }
214-
215- } ,
216-
217- /**
218- * The tint value being applied to the top-right of the Game Object.
219- * This value is interpolated from the corner to the center of the Game Object.
220- *
221- * @name Phaser.GameObjects.Components.Tint#tintTopRight
222- * @type {integer }
223- * @webglOnly
224- * @since 3.0.0
225- */
226- tintTopRight : {
227-
228- get : function ( )
229- {
230- return this . _tintTR ;
231- } ,
232-
233- set : function ( value )
234- {
235- this . _tintTR = GetColorFromValue ( value ) ;
236- this . _isTinted = true ;
237- }
238-
239- } ,
240-
241- /**
242- * The tint value being applied to the bottom-left of the Game Object.
243- * This value is interpolated from the corner to the center of the Game Object.
244- *
245- * @name Phaser.GameObjects.Components.Tint#tintBottomLeft
246- * @type {integer }
247- * @webglOnly
248- * @since 3.0.0
249- */
250- tintBottomLeft : {
251-
252- get : function ( )
253- {
254- return this . _tintBL ;
255- } ,
256-
257- set : function ( value )
258- {
259- this . _tintBL = GetColorFromValue ( value ) ;
260- this . _isTinted = true ;
261- }
262-
263- } ,
264-
265- /**
266- * The tint value being applied to the bottom-right of the Game Object.
267- * This value is interpolated from the corner to the center of the Game Object.
268- *
269- * @name Phaser.GameObjects.Components.Tint#tintBottomRight
270- * @type {integer }
271- * @webglOnly
272- * @since 3.0.0
273- */
274- tintBottomRight : {
275-
276- get : function ( )
277- {
278- return this . _tintBR ;
279- } ,
280-
281- set : function ( value )
282- {
283- this . _tintBR = GetColorFromValue ( value ) ;
284- this . _isTinted = true ;
285- }
286-
287- } ,
288-
289183 /**
290184 * The tint value being applied to the whole of the Game Object.
291185 * This property is a setter-only. Use the properties `tintTopLeft` etc to read the current tint value.
@@ -304,7 +198,10 @@ var Tint = {
304198 } ,
305199
306200 /**
307- * Does this Game Object have a tint applied to it or not?
201+ * Does this Game Object have a tint applied?
202+ *
203+ * It checks to see if the 4 tint properties are set to the value 0xffffff
204+ * and that the `tintFill` property is `false`. This indicates that a Game Object isn't tinted.
308205 *
309206 * @name Phaser.GameObjects.Components.Tint#isTinted
310207 * @type {boolean }
@@ -316,7 +213,15 @@ var Tint = {
316213
317214 get : function ( )
318215 {
319- return this . _isTinted ;
216+ var white = 0xffffff ;
217+
218+ return (
219+ this . tintFill ||
220+ this . tintTopLeft !== white ||
221+ this . tintTopRight !== white ||
222+ this . tintBottomLeft !== white ||
223+ this . tintBottomRight !== white
224+ ) ;
320225 }
321226
322227 }
0 commit comments