From ef85b8415d06258b166f7021d267860fd819e481 Mon Sep 17 00:00:00 2001 From: photonstorm Date: Tue, 30 Sep 2014 21:07:57 +0100 Subject: [PATCH] If you pass a tinted Sprite to `BitmapData.draw` or `BitmapData.copy` it will now draw the tinted version of the Sprite to the BitmapData and not the original texture. --- README.md | 1 + src/gameobjects/BitmapData.js | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/README.md b/README.md index 9ef9fd078..8532cf62a 100644 --- a/README.md +++ b/README.md @@ -87,6 +87,7 @@ Version 2.1.2 - "Whitebridge" - in development * Sound.fadeIn(duration, loop) will start the Sound playing, or restart it if already playing, set its volume to zero and then increase the volume over the duration given until it reaches 1. At the end of the fade the Sound.onFadeComplete event is dispatched. * Text.addColor allows you to set specific colors 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. * Text.clearColors resets any previously set colors from `Text.addColor`. +* If you pass a tinted Sprite to `BitmapData.draw` or `BitmapData.copy` it will now draw the tinted version of the Sprite to the BitmapData and not the original texture. diff --git a/src/gameobjects/BitmapData.js b/src/gameobjects/BitmapData.js index 05398bda2..4ff681870 100644 --- a/src/gameobjects/BitmapData.js +++ b/src/gameobjects/BitmapData.js @@ -889,6 +889,17 @@ Phaser.BitmapData.prototype = { tx += source.texture.trim.x - source.anchor.x * source.texture.trim.width; ty += source.texture.trim.y - source.anchor.y * source.texture.trim.height; } + + if (source.tint !== 0xFFFFFF) + { + if (source.cachedTint !== source.tint) + { + source.cachedTint = source.tint; + source.tintedTexture = PIXI.CanvasTinter.getTintedTexture(source, source.tint); + } + + this._image = source.tintedTexture; + } } else {