Skip to content

Commit 60b23a1

Browse files
committed
Added tint to Color component.
1 parent 3020e3b commit 60b23a1

1 file changed

Lines changed: 48 additions & 1 deletion

File tree

src/components/Color.js

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Phaser.Component.Color = function (gameObject)
2323

2424
this._blendMode = 0;
2525

26-
this._tint = [];
26+
this._tint = [ 0xffffff, 0xffffff, 0xffffff, 0xffffff ];
2727
this._hasTint = false;
2828

2929
this._r = 0;
@@ -56,6 +56,25 @@ Phaser.Component.Color.prototype = {
5656
this.setDirty();
5757
},
5858

59+
clearTint: function ()
60+
{
61+
this._hasTint = false;
62+
63+
this.setDirty();
64+
},
65+
66+
setTint: function (topLeft, topRight, bottomLeft, bottomRight)
67+
{
68+
this._tint[0] = topLeft;
69+
this._tint[1] = topRight;
70+
this._tint[2] = bottomLeft;
71+
this._tint[3] = bottomRight;
72+
73+
this._hasTint = true;
74+
75+
this.setDirty();
76+
},
77+
5978
getBlendMode: function ()
6079
{
6180
return this._blendMode;
@@ -102,6 +121,34 @@ Phaser.Component.Color.prototype = {
102121

103122
Object.defineProperties(Phaser.Component.Color.prototype, {
104123

124+
tint: {
125+
126+
enumerable: true,
127+
128+
get: function ()
129+
{
130+
return this._tint;
131+
},
132+
133+
set: function (value)
134+
{
135+
if (Array.isArray(value))
136+
{
137+
this._tint = value;
138+
}
139+
else
140+
{
141+
this._tint[0] = value;
142+
this._tint[1] = value;
143+
this._tint[2] = value;
144+
this._tint[3] = value;
145+
}
146+
147+
this.setDirty();
148+
}
149+
150+
},
151+
105152
alpha: {
106153

107154
enumerable: true,

0 commit comments

Comments
 (0)