A tinted Texture in Canvas mode wouldn't be updated properly if it was also cropped, beyond the initial crop. Now a cropped texture will re-tint itself every time the crop is updated, and has changed (thanks @phoenixyjll #2688)

This commit is contained in:
photonstorm 2016-08-18 15:55:13 +01:00
parent 04e70e820c
commit 4382944a2e
2 changed files with 13 additions and 2 deletions

View file

@ -345,6 +345,7 @@ You can read all about the philosophy behind Lazer [here](http://phaser.io/news/
* Sound.play would throw the error "Uncaught DOMException: Failed to execute 'disconnect' on 'AudioNode': the given destination is not connected." in Chrome, if you tried to play an audio marker that didn't exist, while a valid marker was already playing.
* Text bounds would incorrectly displace if the Text resolution was greater than 1 (thanks @valent-novem #2685)
* TilemapParser would calculate widthInPixels and heightInPixels were being read incorrectly from JSON data (capitalisation of properties) (thanks @hexus #2691)
* A tinted Texture in Canvas mode wouldn't be updated properly if it was also cropped, beyond the initial crop. Now a cropped texture will re-tint itself every time the crop is updated, and has changed (thanks @phoenixyjll #2688)
### Pixi Updates

View file

@ -46,7 +46,7 @@ Phaser.Component.Crop.prototype = {
* @param {Phaser.Rectangle} rect - The Rectangle used during cropping. Pass null or no parameters to clear a previously set crop rectangle.
* @param {boolean} [copy=false] - If false `cropRect` will be stored as a reference to the given rect. If true it will copy the rect values into a local Phaser Rectangle object stored in cropRect.
*/
crop: function(rect, copy) {
crop: function (rect, copy) {
if (copy === undefined) { copy = false; }
@ -83,13 +83,18 @@ Phaser.Component.Crop.prototype = {
*
* @method
*/
updateCrop: function() {
updateCrop: function () {
if (!this.cropRect)
{
return;
}
var oldX = this.texture.crop.x;
var oldY = this.texture.crop.y;
var oldW = this.texture.crop.width;
var oldH = this.texture.crop.height;
this._crop = Phaser.Rectangle.clone(this.cropRect, this._crop);
this._crop.x += this._frame.x;
this._crop.y += this._frame.y;
@ -112,6 +117,11 @@ Phaser.Component.Crop.prototype = {
this.texture._updateUvs();
if (this.tint !== 0xffffff && (oldX !== cx || oldY !== cy || oldW !== cw || oldH !== ch))
{
this.texture.requiresReTint = true;
}
}
};