Skip to content

Commit 8f14483

Browse files
committed
Merge pull request phaserjs#243 from jcd-as/dev
move 'dirty' flag for Tilemap to a per-layer flag. Fixes phaserjs#242
2 parents 666df67 + 539dcdd commit 8f14483

2 files changed

Lines changed: 11 additions & 21 deletions

File tree

src/tilemap/Tilemap.js

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,6 @@ Phaser.Tilemap = function (game, key) {
4848

4949
this.debugMap = [];
5050

51-
/**
52-
* @property {boolean} dirty - Internal rendering related flag.
53-
*/
54-
this.dirty = false;
55-
5651
/**
5752
* @property {array} _results - Internal var.
5853
* @private
@@ -120,14 +115,12 @@ Phaser.Tilemap.prototype = {
120115
tileSpacing: 0,
121116
format: Phaser.Tilemap.CSV,
122117
data: data,
123-
indexes: []
124-
118+
indexes: [],
119+
dirty: true
125120
});
126121

127122
this.currentLayer = this.layers.length - 1;
128123

129-
this.dirty = true;
130-
131124
},
132125

133126
/**
@@ -187,10 +180,9 @@ Phaser.Tilemap.prototype = {
187180
if (x >= 0 && x < this.layers[layer].width && y >= 0 && y < this.layers[layer].height)
188181
{
189182
this.layers[layer].data[y][x] = index;
183+
this.layers[layer].dirty = true;
190184
}
191185

192-
this.dirty = true;
193-
194186
},
195187

196188
/**
@@ -254,10 +246,9 @@ Phaser.Tilemap.prototype = {
254246
if (x >= 0 && x < this.layers[layer].width && y >= 0 && y < this.layers[layer].height)
255247
{
256248
this.layers[layer].data[y][x] = index;
249+
this.layers[layer].dirty = true;
257250
}
258251

259-
this.dirty = true;
260-
261252
},
262253

263254
/**
@@ -349,8 +340,7 @@ Phaser.Tilemap.prototype = {
349340
this.layers[layer].data[ diffY + tileblock[i].y ][ diffX + tileblock[i].x ] = tileblock[i].index;
350341
}
351342

352-
this.dirty = true;
353-
343+
this.layers[layer].dirty = true;
354344
},
355345

356346
/**

src/tilemap/TilemapLayer.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ Phaser.TilemapLayer.prototype.updateMapData = function (tilemap, layer) {
359359
this.layer = this.tilemap.layers[layer];
360360
this.index = layer;
361361
this.updateMax();
362-
this.tilemap.dirty = true;
362+
this.tilemap.layers[layer].dirty = true;
363363
}
364364

365365
}
@@ -633,7 +633,7 @@ Phaser.TilemapLayer.prototype.updateMax = function () {
633633
*/
634634
Phaser.TilemapLayer.prototype.render = function () {
635635

636-
if (this.tilemap && this.tilemap.dirty)
636+
if (this.tilemap && this.tilemap.layers[this.index].dirty )
637637
{
638638
this.dirty = true;
639639
}
@@ -694,10 +694,10 @@ Phaser.TilemapLayer.prototype.render = function () {
694694

695695
this.dirty = false;
696696

697-
if (this.tilemap.dirty)
698-
{
699-
this.tilemap.dirty = false;
700-
}
697+
if( this.tilemap.layers[this.index].dirty )
698+
{
699+
this.tilemap.layers[this.index].dirty = false;
700+
}
701701

702702
return true;
703703

0 commit comments

Comments
 (0)