Merge pull request #5193 from scott20145/master

Fix nested mask behaviour for Phaser.CANVAS mode
This commit is contained in:
Richard Davey 2020-07-13 12:54:14 +01:00 committed by GitHub
commit 259b702df8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 1 deletions

View file

@ -56,6 +56,10 @@ var ContainerCanvasRenderer = function (renderer, container, interpolationPercen
var scrollFactorX = container.scrollFactorX;
var scrollFactorY = container.scrollFactorY;
if (container.mask) {
container.mask.preRenderCanvas(renderer, null, camera);
}
for (var i = 0; i < children.length; i++)
{
var child = children[i];
@ -86,6 +90,11 @@ var ContainerCanvasRenderer = function (renderer, container, interpolationPercen
child.setAlpha(childAlpha);
child.setScrollFactor(childScrollFactorX, childScrollFactorY);
}
if (container.mask) {
container.mask.postRenderCanvas(renderer);
}
};
module.exports = ContainerCanvasRenderer;

View file

@ -767,8 +767,16 @@ var CanvasRenderer = new Class({
ctx.imageSmoothingEnabled = !(!this.antialias || frame.source.scaleMode);
if (sprite.mask) {
sprite.mask.preRenderCanvas(this, sprite, camera);
}
ctx.drawImage(frame.source.image, frameX, frameY, frameWidth, frameHeight, x, y, frameWidth / res, frameHeight / res);
if (sprite.mask) {
sprite.mask.postRenderCanvas(this, sprite, camera);
}
ctx.restore();
},