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.

This commit is contained in:
photonstorm 2014-09-30 21:07:57 +01:00
parent e8ca670fba
commit ef85b8415d
2 changed files with 12 additions and 0 deletions

View file

@ -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.

View file

@ -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
{