Phaser.TilemapParser.INSERT_NULL is a new boolean that controls what happens when the parser encounters an empty tile: When scanning the Tiled map data the TilemapParser can either insert a null value (true) or a Phaser.Tile instance with an index of -1 (false, the default). Depending on your game type depends how this should be configured. If you've a large sparsely populated map and the tile data doesn't need to change then setting this value to true will help with memory consumption. However if your map is small, or you need to update the tiles (perhaps the map dynamically changes during the game) then leave the default value set (thanks #1982)

This commit is contained in:
photonstorm 2015-08-24 12:36:23 +01:00
parent 0cce3f8287
commit cc7b632a37
2 changed files with 22 additions and 3 deletions

View file

@ -275,6 +275,7 @@ If you are an exceptional JavaScript developer and would like to join the Phaser
* BitmapData.line draws a line to the BitmapData in the color and thickness specified.
* BitmapData.op is a handy short-code to get and set the canvas global composite operator.
* BitmapData.drawFull draws the given Game Object or Group to a BitmapData and then recursively iterates through all of its children, including children of Game Objects and Groups. It can draw Text, BitmapText, Sprites, Images, Emitters and Graphics objects. It's perfectly valid to pass in `game.world` as the parent object, and it will iterate through the entire display list.
* Phaser.TilemapParser.INSERT_NULL is a new boolean that controls what happens when the parser encounters an empty tile: When scanning the Tiled map data the TilemapParser can either insert a null value (true) or a `Phaser.Tile` instance with an index of -1 (false, the default). Depending on your game type depends how this should be configured. If you've a large sparsely populated map and the tile data doesn't need to change then setting this value to `true` will help with memory consumption. However if your map is small, or you need to update the tiles (perhaps the map dynamically changes during the game) then leave the default value set (thanks #1982)
### Updates

View file

@ -8,9 +8,22 @@
* Phaser.TilemapParser parses data objects from Phaser.Loader that need more preparation before they can be inserted into a Tilemap.
*
* @class Phaser.TilemapParser
* @static
*/
Phaser.TilemapParser = {
/**
* When scanning the Tiled map data the TilemapParser can either insert a null value (true) or
* a Phaser.Tile instance with an index of -1 (false, the default). Depending on your game type
* depends how this should be configured. If you've a large sparsely populated map and the tile
* data doesn't need to change then setting this value to `true` will help with memory consumption.
* However if your map is small, or you need to update the tiles (perhaps the map dynamically changes
* during the game) then leave the default value set.
*
* @type {boolean}
*/
INSERT_NULL: false,
/**
* Parse tilemap data from the cache and creates a Tilemap object.
*
@ -324,9 +337,14 @@ Phaser.TilemapParser = {
}
else
{
// Null option
// row.push(new Phaser.Tile(layer, -1, x, output.length, json.tilewidth, json.tileheight));
row.push(null);
if (Phaser.TilemapParser.INSERT_NULL)
{
row.push(null);
}
else
{
row.push(new Phaser.Tile(layer, -1, x, output.length, json.tilewidth, json.tileheight));
}
}
x++;