Merge pull request #951 from sivael/dev

TileMap update performance
This commit is contained in:
Richard Davey 2014-07-01 16:17:20 +01:00
commit a127080794

View file

@ -883,6 +883,28 @@ Phaser.Tilemap.prototype = {
},
/**
* Turn off/on the recalculation of faces for tile or collission updates.
* setPreventRecalculate(true) puts recalculation on hold while
* setPreventRecalculate(false) recalculates all the changed layers.
*
* @method Phaser.Tilemap#setPreventRecalculate
* @param {boolean} if true it will put the recalculation on hold.
*/
setPreventRecalculate: function (value) {
if((value===true)&&(this.preventingRecalculate!==true)){
this.preventingRecalculate = true;
this.needToRecalculate = {};
}
if((value===false)&&(this.preventingRecalculate===true)){
this.preventingRecalculate = false;
for(var i in this.needToRecalculate){
this.calculateFaces(i);
}
this.needToRecalculate = false;
}
},
/**
* Internal function.
*
@ -892,6 +914,11 @@ Phaser.Tilemap.prototype = {
*/
calculateFaces: function (layer) {
if(this.preventingRecalculate===true){
this.needToRecalculate[layer] = true;
return;
}
var above = null;
var below = null;
var left = null;