Merge pull request #243 from jcd-as/dev

move 'dirty' flag for Tilemap to a per-layer flag. Fixes #242
This commit is contained in:
Richard Davey 2013-12-04 14:38:55 -08:00
commit 8f14483b60
2 changed files with 11 additions and 21 deletions

View file

@ -48,11 +48,6 @@ Phaser.Tilemap = function (game, key) {
this.debugMap = [];
/**
* @property {boolean} dirty - Internal rendering related flag.
*/
this.dirty = false;
/**
* @property {array} _results - Internal var.
* @private
@ -120,14 +115,12 @@ Phaser.Tilemap.prototype = {
tileSpacing: 0,
format: Phaser.Tilemap.CSV,
data: data,
indexes: []
indexes: [],
dirty: true
});
this.currentLayer = this.layers.length - 1;
this.dirty = true;
},
/**
@ -187,10 +180,9 @@ Phaser.Tilemap.prototype = {
if (x >= 0 && x < this.layers[layer].width && y >= 0 && y < this.layers[layer].height)
{
this.layers[layer].data[y][x] = index;
this.layers[layer].dirty = true;
}
this.dirty = true;
},
/**
@ -254,10 +246,9 @@ Phaser.Tilemap.prototype = {
if (x >= 0 && x < this.layers[layer].width && y >= 0 && y < this.layers[layer].height)
{
this.layers[layer].data[y][x] = index;
this.layers[layer].dirty = true;
}
this.dirty = true;
},
/**
@ -349,8 +340,7 @@ Phaser.Tilemap.prototype = {
this.layers[layer].data[ diffY + tileblock[i].y ][ diffX + tileblock[i].x ] = tileblock[i].index;
}
this.dirty = true;
this.layers[layer].dirty = true;
},
/**

View file

@ -359,7 +359,7 @@ Phaser.TilemapLayer.prototype.updateMapData = function (tilemap, layer) {
this.layer = this.tilemap.layers[layer];
this.index = layer;
this.updateMax();
this.tilemap.dirty = true;
this.tilemap.layers[layer].dirty = true;
}
}
@ -633,7 +633,7 @@ Phaser.TilemapLayer.prototype.updateMax = function () {
*/
Phaser.TilemapLayer.prototype.render = function () {
if (this.tilemap && this.tilemap.dirty)
if (this.tilemap && this.tilemap.layers[this.index].dirty )
{
this.dirty = true;
}
@ -694,10 +694,10 @@ Phaser.TilemapLayer.prototype.render = function () {
this.dirty = false;
if (this.tilemap.dirty)
{
this.tilemap.dirty = false;
}
if( this.tilemap.layers[this.index].dirty )
{
this.tilemap.layers[this.index].dirty = false;
}
return true;