diff --git a/src/tilemap/Tilemap.js b/src/tilemap/Tilemap.js index d29d8ac55..fb1eef89b 100644 --- a/src/tilemap/Tilemap.js +++ b/src/tilemap/Tilemap.js @@ -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;