Skip to content

Commit dcc83ec

Browse files
committed
Tilemap renderer - context save/restore
- Added context save/restore; the secondary issue when the canvas is copied from later, and if any alpha is applied
1 parent 54dba67 commit dcc83ec

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

src/tilemap/TilemapLayer.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -798,7 +798,7 @@ Phaser.TilemapLayer.prototype.renderRegion = function (scrollX, scrollY, left, t
798798
var th = this._mc.tileHeight;
799799

800800
var tilesets = this._mc.tilesets;
801-
var lastAlpha = 1;
801+
var lastAlpha = NaN;
802802

803803
if (!this._wrap)
804804
{
@@ -827,10 +827,7 @@ Phaser.TilemapLayer.prototype.renderRegion = function (scrollX, scrollY, left, t
827827
// xmax/ymax - remaining cells to render on column/row
828828
var tx, ty, x, y, xmax, ymax;
829829

830-
// Restore assumed states
831-
context.globalAlpha = 1;
832830
context.fillStyle = this.tileColor;
833-
context.globalCompositeOperation = 'source-over';
834831

835832
for (y = normStartY, ymax = bottom - top, ty = baseY;
836833
ymax >= 0;
@@ -1030,6 +1027,8 @@ Phaser.TilemapLayer.prototype.render = function () {
10301027
return;
10311028
}
10321029

1030+
this.context.save();
1031+
10331032
if (this.dirty || this.layer.dirty)
10341033
{
10351034
this.layer.dirty = false;
@@ -1097,6 +1096,8 @@ Phaser.TilemapLayer.prototype.render = function () {
10971096

10981097
this.dirty = false;
10991098

1099+
this.context.restore();
1100+
11001101
return true;
11011102

11021103
};

0 commit comments

Comments
 (0)