Skip to content

Commit 0cce3f8

Browse files
committed
Enabling a filter on a display object that had a blend mode set would cause the object to become invisible. The two cannot be combined, so when you set a filter on a display object it now automatically resets the blend mode to NORMAL. The same does not happen in reverse however, so if you've got a filter set and then change the blend mode it will still break. Be careful to capture this yourself (thanks @wayfu phaserjs#1994)
1 parent 5056eed commit 0cce3f8

3 files changed

Lines changed: 15 additions & 2 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ If you are an exceptional JavaScript developer and would like to join the Phaser
308308
* TilingSprite._renderCanvas wasn't correctly allowing for pixel rounding (thanks @ximop #2022)
309309
* Cache.addSpriteSheet didn't include default values for the `frameMax`, `margin` and `spacing` arguments (thanks @vladkens #2017 #2018)
310310
* Tilemap.shuffle was calling the deprecated Phaser.Utils.shuffle, which has now moved to Phaser.ArrayUtils.shuffle.
311+
* Enabling a filter on a display object that had a blend mode set would cause the object to become invisible. The two cannot be combined, so when you set a filter on a display object it now automatically resets the blend mode to `NORMAL`. The same does not happen in reverse however, so if you've got a filter set and then change the blend mode it will still break. Be careful to capture this yourself (thanks @wayfu #1994)
311312

312313
For changes in previous releases please see the extensive [Version History](https://github.com/photonstorm/phaser/blob/master/CHANGELOG.md).
313314

src/pixi/display/DisplayObject.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,13 @@ Object.defineProperty(PIXI.DisplayObject.prototype, 'mask', {
327327

328328
/**
329329
* Sets the filters for the displayObject.
330-
* * IMPORTANT: This is a webGL only feature and will be ignored by the canvas renderer.
331-
* To remove filters simply set this property to 'null'
330+
* IMPORTANT: This is a webGL only feature and will be ignored by the Canvas renderer.
331+
*
332+
* To remove filters simply set this property to 'null'.
333+
*
334+
* You cannot have a filter and a blend mode active at the same time. Setting a filter will reset
335+
* this objects blend mode to NORMAL.
336+
*
332337
* @property filters
333338
* @type Array(Filter)
334339
*/
@@ -360,6 +365,11 @@ Object.defineProperty(PIXI.DisplayObject.prototype, 'filters', {
360365
}
361366

362367
this._filters = value;
368+
369+
if (this.blendMode)
370+
{
371+
this.blendMode = PIXI.blendModes.NORMAL;
372+
}
363373
}
364374
});
365375

src/pixi/display/Sprite.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ PIXI.Sprite = function(texture)
8787
/**
8888
* The blend mode to be applied to the sprite. Set to PIXI.blendModes.NORMAL to remove any blend mode.
8989
*
90+
* Warning: You cannot have a blend mode and a filter active on the same Sprite. Doing so will render the sprite invisible.
91+
*
9092
* @property blendMode
9193
* @type Number
9294
* @default PIXI.blendModes.NORMAL;

0 commit comments

Comments
 (0)