From 60b23a157e669db9c288122058a109370723f94f Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Sun, 16 Oct 2016 23:51:54 +0100 Subject: [PATCH] Added tint to Color component. --- src/components/Color.js | 49 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/src/components/Color.js b/src/components/Color.js index bbd2fd8ee..4849e28b4 100644 --- a/src/components/Color.js +++ b/src/components/Color.js @@ -23,7 +23,7 @@ Phaser.Component.Color = function (gameObject) this._blendMode = 0; - this._tint = []; + this._tint = [ 0xffffff, 0xffffff, 0xffffff, 0xffffff ]; this._hasTint = false; this._r = 0; @@ -56,6 +56,25 @@ Phaser.Component.Color.prototype = { this.setDirty(); }, + clearTint: function () + { + this._hasTint = false; + + this.setDirty(); + }, + + setTint: function (topLeft, topRight, bottomLeft, bottomRight) + { + this._tint[0] = topLeft; + this._tint[1] = topRight; + this._tint[2] = bottomLeft; + this._tint[3] = bottomRight; + + this._hasTint = true; + + this.setDirty(); + }, + getBlendMode: function () { return this._blendMode; @@ -102,6 +121,34 @@ Phaser.Component.Color.prototype = { Object.defineProperties(Phaser.Component.Color.prototype, { + tint: { + + enumerable: true, + + get: function () + { + return this._tint; + }, + + set: function (value) + { + if (Array.isArray(value)) + { + this._tint = value; + } + else + { + this._tint[0] = value; + this._tint[1] = value; + this._tint[2] = value; + this._tint[3] = value; + } + + this.setDirty(); + } + + }, + alpha: { enumerable: true,