From 73745e572084b357f1be649c1e1d2abc6087aec3 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Thu, 8 Aug 2013 06:29:21 +0100 Subject: [PATCH] Fixed a few things in Tilemap and optimised the renderer a little bit. --- Phaser/renderers/canvas/TilemapRenderer.ts | 20 +++---- Phaser/tilemap/Tilemap.ts | 49 +++++---------- Phaser/tilemap/TilemapLayer.ts | 20 ++++--- README.md | 5 +- Tests/phaser.js | 70 ++++++++++------------ build/phaser.d.ts | 28 ++++----- build/phaser.js | 70 ++++++++++------------ 7 files changed, 106 insertions(+), 156 deletions(-) diff --git a/Phaser/renderers/canvas/TilemapRenderer.ts b/Phaser/renderers/canvas/TilemapRenderer.ts index 7b2c5c826..5b66eb243 100644 --- a/Phaser/renderers/canvas/TilemapRenderer.ts +++ b/Phaser/renderers/canvas/TilemapRenderer.ts @@ -17,20 +17,13 @@ module Phaser.Renderer.Canvas { // Local rendering related temp vars to help avoid gc spikes through constant var creation private _ga: number = 1; - private _sx: number = 0; - private _sy: number = 0; - private _sw: number = 0; - private _sh: number = 0; private _dx: number = 0; private _dy: number = 0; private _dw: number = 0; private _dh: number = 0; - private _fx: number = 1; - private _fy: number = 1; private _tx: number = 0; private _ty: number = 0; - private _sin: number = 0; - private _cos: number = 1; + private _tl: number = 0; private _maxX: number = 0; private _maxY: number = 0; private _startX: number = 0; @@ -44,15 +37,18 @@ module Phaser.Renderer.Canvas { public render(camera: Camera, tilemap: Tilemap): bool { // Loop through the layers - for (var i = 0; i < tilemap.layers.length; i++) - { - var layer: TilemapLayer = tilemap.layers[i]; - if (layer.visible == false || layer.alpha < 0.1) + this._tl = tilemap.layers.length; + + for (var i = 0; i < this._tl; i++) + { + if (tilemap.layers[i].visible == false || tilemap.layers[i].alpha < 0.1) { continue; } + var layer: TilemapLayer = tilemap.layers[i]; + // Work out how many tiles we can fit into our camera and round it up for the edges this._maxX = this.game.math.ceil(camera.width / layer.tileWidth) + 1; this._maxY = this.game.math.ceil(camera.height / layer.tileHeight) + 1; diff --git a/Phaser/tilemap/Tilemap.ts b/Phaser/tilemap/Tilemap.ts index 3d3d3f430..2396b38f2 100644 --- a/Phaser/tilemap/Tilemap.ts +++ b/Phaser/tilemap/Tilemap.ts @@ -117,11 +117,6 @@ module Phaser { */ public transform: Phaser.Components.TransformManager; - /** - * The Events component - */ - //public events: Phaser.Components.Sprite.Events; - /** * z order value of the object. */ @@ -132,10 +127,6 @@ module Phaser { */ public renderOrderID: number = 0; - - - - /** * Tilemap data format enum: CSV. * @type {number} @@ -189,21 +180,6 @@ module Phaser { */ public mapFormat: number; - /** - * Inherited methods for overriding. - */ - public preUpdate() { - } - - public update() { - } - - public postUpdate() { - } - - public destroy() { - } - /** * Parset csv map data and generate tiles. * @param data {string} CSV map data. @@ -213,7 +189,7 @@ module Phaser { */ private parseCSV(data: string, key: string, tileWidth: number, tileHeight: number) { - var layer: TilemapLayer = new TilemapLayer(this.game, this, key, Tilemap.FORMAT_CSV, 'TileLayerCSV' + this.layers.length.toString(), tileWidth, tileHeight); + var layer: TilemapLayer = new TilemapLayer(this, 0, key, Tilemap.FORMAT_CSV, 'TileLayerCSV' + this.layers.length.toString(), tileWidth, tileHeight); // Trim any rogue whitespace from the data data = data.trim(); @@ -257,7 +233,7 @@ module Phaser { for (var i = 0; i < json.layers.length; i++) { - var layer: TilemapLayer = new TilemapLayer(this.game, this, key, Tilemap.FORMAT_TILED_JSON, json.layers[i].name, json.tilewidth, json.tileheight); + var layer: TilemapLayer = new TilemapLayer(this, i, key, Tilemap.FORMAT_TILED_JSON, json.layers[i].name, json.tilewidth, json.tileheight); // Check it's a data layer if (!json.layers[i].data) @@ -401,7 +377,7 @@ module Phaser { * @param [layer] {number} layer of this tile located. * @return {Tile} The tile with specific properties. */ - public getTile(x: number, y: number, layer?: number = 0):Tile { + public getTile(x: number, y: number, layer?: number = this.currentLayer.ID):Tile { return this.tiles[this.layers[layer].getTileIndex(x, y)]; @@ -414,7 +390,7 @@ module Phaser { * @param [layer] {number} layer of this tile located. * @return {Tile} The tile with specific properties. */ - public getTileFromWorldXY(x: number, y: number, layer?: number = 0):Tile { + public getTileFromWorldXY(x: number, y: number, layer?: number = this.currentLayer.ID):Tile { return this.tiles[this.layers[layer].getTileFromWorldXY(x, y)]; @@ -425,7 +401,7 @@ module Phaser { * @param layer The layer to check, defaults to 0 * @returns {Tile} */ - public getTileFromInputXY(layer?: number = 0):Tile { + public getTileFromInputXY(layer?: number = this.currentLayer.ID):Tile { return this.tiles[this.layers[layer].getTileFromWorldXY(this.game.input.worldX, this.game.input.worldY)]; @@ -507,16 +483,21 @@ module Phaser { * @param index {number} The index of this tile type in the core map data. * @param [layer] {number} which layer you want to set the tile to. */ - public putTile(x: number, y: number, index: number, layer?: number = 0) { + public putTile(x: number, y: number, index: number, layer?: number = this.currentLayer.ID) { this.layers[layer].putTile(x, y, index); } - // Set current layer - // Set layer order? - // Delete tiles of certain type - // Erase tiles + public destroy() { + + this.texture = null; + this.transform = null; + + this.tiles.length = 0; + this.layers.length = 0; + + } } diff --git a/Phaser/tilemap/TilemapLayer.ts b/Phaser/tilemap/TilemapLayer.ts index 6bf0f1179..18925ba2c 100644 --- a/Phaser/tilemap/TilemapLayer.ts +++ b/Phaser/tilemap/TilemapLayer.ts @@ -16,19 +16,20 @@ module Phaser { * TilemapLayer constructor * Create a new TilemapLayer. * - * @param game {Phaser.Game} Current game instance. * @param parent {Tilemap} The tilemap that contains this layer. + * @param id {number} The ID of this layer within the Tilemap array. * @param key {string} Asset key for this map. * @param mapFormat {number} Format of this map data, available: Tilemap.FORMAT_CSV or Tilemap.FORMAT_TILED_JSON. * @param name {string} Name of this layer, so you can get this layer by its name. * @param tileWidth {number} Width of tiles in this map. * @param tileHeight {number} Height of tiles in this map. */ - constructor(game: Game, parent:Tilemap, key: string, mapFormat: number, name: string, tileWidth: number, tileHeight: number) { + constructor(parent:Tilemap, id:number, key: string, mapFormat: number, name: string, tileWidth: number, tileHeight: number) { - this.game = game; this.parent = parent; + this.game = parent.game; + this.ID = id; this.name = name; this.mapFormat = mapFormat; this.tileWidth = tileWidth; @@ -97,6 +98,12 @@ module Phaser { */ public name: string; + /** + * The ID of the layer within the Tilemap. + * @type {number} + */ + public ID: number; + /** * Controls whether update() and draw() are automatically called. * @type {boolean} @@ -109,11 +116,6 @@ module Phaser { */ public visible: bool = true; - /** - * @type {string} - */ - //public orientation: string; - /** * Properties of this map layer. (normally set by map editors) */ @@ -131,7 +133,7 @@ module Phaser { public mapFormat: number; /** - * It's width and height are in tiles instead of pixels. + * Map bounds (width and height) in tiles not pixels. * @type {Rectangle} */ public boundsInTiles: Rectangle; diff --git a/README.md b/README.md index 247acc49f..0aedba924 100644 --- a/README.md +++ b/README.md @@ -29,14 +29,12 @@ Future Plans * Add ability to create extra
s within the game container, layered above/below the canvas * Basic Window UI component (maybe a propogating Group?) * Add clip support + shape options to Texture Component. +* Tilemap: remove tiles of a certain type, replace tile with sprite, change layer order ToDo before release ------------------- -* Tilemap.render - move layers length to var -* Tilemap.destroy needs doing * Investigate bug re: tilemap collision and animation frames -* Need to be able to set the current tilemap layer, then the getTileXY default layer uses that one if no other given * Allow camera to directly render to the stage rather than hidden ctx (maybe does this by default? or have under Mobile Optimisations list) * Sprite collision events * Check bounds/edge points when sprite is only 1x1 sized :) @@ -49,6 +47,7 @@ ToDo before release * Pixel-perfect click check * Check Flash atlas export is supported * DynamicTexture.setPixel needs to be swapped for a proper pixel put, not the filledRect it currently is. +* TypeScript 0.9.1 update! Latest Update ------------- diff --git a/Tests/phaser.js b/Tests/phaser.js index 735ab6f18..9b3e45bb0 100644 --- a/Tests/phaser.js +++ b/Tests/phaser.js @@ -11521,15 +11521,15 @@ var Phaser; * TilemapLayer constructor * Create a new TilemapLayer. * - * @param game {Phaser.Game} Current game instance. * @param parent {Tilemap} The tilemap that contains this layer. + * @param id {number} The ID of this layer within the Tilemap array. * @param key {string} Asset key for this map. * @param mapFormat {number} Format of this map data, available: Tilemap.FORMAT_CSV or Tilemap.FORMAT_TILED_JSON. * @param name {string} Name of this layer, so you can get this layer by its name. * @param tileWidth {number} Width of tiles in this map. * @param tileHeight {number} Height of tiles in this map. */ - function TilemapLayer(game, parent, key, mapFormat, name, tileWidth, tileHeight) { + function TilemapLayer(parent, id, key, mapFormat, name, tileWidth, tileHeight) { /** * Controls whether update() and draw() are automatically called. * @type {boolean} @@ -11572,8 +11572,9 @@ var Phaser; * @type {number} */ this.tileSpacing = 0; - this.game = game; this.parent = parent; + this.game = parent.game; + this.ID = id; this.name = name; this.mapFormat = mapFormat; this.tileWidth = tileWidth; @@ -12028,10 +12029,6 @@ var Phaser; if (typeof tileWidth === "undefined") { tileWidth = 0; } if (typeof tileHeight === "undefined") { tileHeight = 0; } /** - * The Events component - */ - //public events: Phaser.Components.Sprite.Events; - /** * z order value of the object. */ this.z = -1; @@ -12072,17 +12069,6 @@ var Phaser; } Tilemap.FORMAT_CSV = 0; Tilemap.FORMAT_TILED_JSON = 1; - Tilemap.prototype.preUpdate = /** - * Inherited methods for overriding. - */ - function () { - }; - Tilemap.prototype.update = function () { - }; - Tilemap.prototype.postUpdate = function () { - }; - Tilemap.prototype.destroy = function () { - }; Tilemap.prototype.parseCSV = /** * Parset csv map data and generate tiles. * @param data {string} CSV map data. @@ -12091,7 +12077,7 @@ var Phaser; * @param tileHeight {number} Height of its tile. */ function (data, key, tileWidth, tileHeight) { - var layer = new Phaser.TilemapLayer(this.game, this, key, Tilemap.FORMAT_CSV, 'TileLayerCSV' + this.layers.length.toString(), tileWidth, tileHeight); + var layer = new Phaser.TilemapLayer(this, 0, key, Tilemap.FORMAT_CSV, 'TileLayerCSV' + this.layers.length.toString(), tileWidth, tileHeight); // Trim any rogue whitespace from the data data = data.trim(); var rows = data.split("\n"); @@ -12118,7 +12104,7 @@ var Phaser; data = data.trim(); var json = JSON.parse(data); for(var i = 0; i < json.layers.length; i++) { - var layer = new Phaser.TilemapLayer(this.game, this, key, Tilemap.FORMAT_TILED_JSON, json.layers[i].name, json.tilewidth, json.tileheight); + var layer = new Phaser.TilemapLayer(this, i, key, Tilemap.FORMAT_TILED_JSON, json.layers[i].name, json.tilewidth, json.tileheight); // Check it's a data layer if(!json.layers[i].data) { continue; @@ -12236,7 +12222,7 @@ var Phaser; * @return {Tile} The tile with specific properties. */ function (x, y, layer) { - if (typeof layer === "undefined") { layer = 0; } + if (typeof layer === "undefined") { layer = this.currentLayer.ID; } return this.tiles[this.layers[layer].getTileIndex(x, y)]; }; Tilemap.prototype.getTileFromWorldXY = /** @@ -12247,7 +12233,7 @@ var Phaser; * @return {Tile} The tile with specific properties. */ function (x, y, layer) { - if (typeof layer === "undefined") { layer = 0; } + if (typeof layer === "undefined") { layer = this.currentLayer.ID; } return this.tiles[this.layers[layer].getTileFromWorldXY(x, y)]; }; Tilemap.prototype.getTileFromInputXY = /** @@ -12256,7 +12242,7 @@ var Phaser; * @returns {Tile} */ function (layer) { - if (typeof layer === "undefined") { layer = 0; } + if (typeof layer === "undefined") { layer = this.currentLayer.ID; } return this.tiles[this.layers[layer].getTileFromWorldXY(this.game.input.worldX, this.game.input.worldY)]; }; Tilemap.prototype.getTileOverlaps = /** @@ -12317,17 +12303,19 @@ var Phaser; * @param [layer] {number} which layer you want to set the tile to. */ function (x, y, index, layer) { - if (typeof layer === "undefined") { layer = 0; } + if (typeof layer === "undefined") { layer = this.currentLayer.ID; } this.layers[layer].putTile(x, y, index); }; + Tilemap.prototype.destroy = function () { + this.texture = null; + this.transform = null; + this.tiles.length = 0; + this.layers.length = 0; + }; return Tilemap; })(); Phaser.Tilemap = Tilemap; - // Set current layer - // Set layer order? - // Delete tiles of certain type - // Erase tiles - })(Phaser || (Phaser = {})); +})(Phaser || (Phaser = {})); /// /// /// @@ -18011,20 +17999,21 @@ var Phaser; function TilemapRenderer(game) { // Local rendering related temp vars to help avoid gc spikes through constant var creation this._ga = 1; - this._sx = 0; - this._sy = 0; - this._sw = 0; - this._sh = 0; + //private _sx: number = 0; + //private _sy: number = 0; + //private _sw: number = 0; + //private _sh: number = 0; this._dx = 0; this._dy = 0; this._dw = 0; this._dh = 0; - this._fx = 1; - this._fy = 1; + //private _fx: number = 1; + //private _fy: number = 1; this._tx = 0; this._ty = 0; - this._sin = 0; - this._cos = 1; + this._tl = 0; + //private _sin: number = 0; + //private _cos: number = 1; this._maxX = 0; this._maxY = 0; this._startX = 0; @@ -18037,11 +18026,12 @@ var Phaser; */ function (camera, tilemap) { // Loop through the layers - for(var i = 0; i < tilemap.layers.length; i++) { - var layer = tilemap.layers[i]; - if(layer.visible == false || layer.alpha < 0.1) { + this._tl = tilemap.layers.length; + for(var i = 0; i < this._tl; i++) { + if(tilemap.layers[i].visible == false || tilemap.layers[i].alpha < 0.1) { continue; } + var layer = tilemap.layers[i]; // Work out how many tiles we can fit into our camera and round it up for the edges this._maxX = this.game.math.ceil(camera.width / layer.tileWidth) + 1; this._maxY = this.game.math.ceil(camera.height / layer.tileHeight) + 1; diff --git a/build/phaser.d.ts b/build/phaser.d.ts index 4dff60347..6fb44cc15 100644 --- a/build/phaser.d.ts +++ b/build/phaser.d.ts @@ -5867,15 +5867,15 @@ module Phaser { * TilemapLayer constructor * Create a new TilemapLayer. * - * @param game {Phaser.Game} Current game instance. * @param parent {Tilemap} The tilemap that contains this layer. + * @param id {number} The ID of this layer within the Tilemap array. * @param key {string} Asset key for this map. * @param mapFormat {number} Format of this map data, available: Tilemap.FORMAT_CSV or Tilemap.FORMAT_TILED_JSON. * @param name {string} Name of this layer, so you can get this layer by its name. * @param tileWidth {number} Width of tiles in this map. * @param tileHeight {number} Height of tiles in this map. */ - constructor(game: Game, parent: Tilemap, key: string, mapFormat: number, name: string, tileWidth: number, tileHeight: number); + constructor(parent: Tilemap, id: number, key: string, mapFormat: number, name: string, tileWidth: number, tileHeight: number); private _tempTileX; private _tempTileY; private _tempTileW; @@ -5910,6 +5910,11 @@ module Phaser { */ public name: string; /** + * The ID of the layer within the Tilemap. + * @type {number} + */ + public ID: number; + /** * Controls whether update() and draw() are automatically called. * @type {boolean} */ @@ -5933,7 +5938,7 @@ module Phaser { */ public mapFormat: number; /** - * It's width and height are in tiles instead of pixels. + * Map bounds (width and height) in tiles not pixels. * @type {Rectangle} */ public boundsInTiles: Rectangle; @@ -6310,13 +6315,6 @@ module Phaser { */ public mapFormat: number; /** - * Inherited methods for overriding. - */ - public preUpdate(): void; - public update(): void; - public postUpdate(): void; - public destroy(): void; - /** * Parset csv map data and generate tiles. * @param data {string} CSV map data. * @param key {string} Asset key for tileset image. @@ -6418,6 +6416,7 @@ module Phaser { * @param [layer] {number} which layer you want to set the tile to. */ public putTile(x: number, y: number, index: number, layer?: number): void; + public destroy(): void; } } /** @@ -9381,20 +9380,13 @@ module Phaser.Renderer.Canvas { */ public game: Game; private _ga; - private _sx; - private _sy; - private _sw; - private _sh; private _dx; private _dy; private _dw; private _dh; - private _fx; - private _fy; private _tx; private _ty; - private _sin; - private _cos; + private _tl; private _maxX; private _maxY; private _startX; diff --git a/build/phaser.js b/build/phaser.js index 735ab6f18..9b3e45bb0 100644 --- a/build/phaser.js +++ b/build/phaser.js @@ -11521,15 +11521,15 @@ var Phaser; * TilemapLayer constructor * Create a new TilemapLayer. * - * @param game {Phaser.Game} Current game instance. * @param parent {Tilemap} The tilemap that contains this layer. + * @param id {number} The ID of this layer within the Tilemap array. * @param key {string} Asset key for this map. * @param mapFormat {number} Format of this map data, available: Tilemap.FORMAT_CSV or Tilemap.FORMAT_TILED_JSON. * @param name {string} Name of this layer, so you can get this layer by its name. * @param tileWidth {number} Width of tiles in this map. * @param tileHeight {number} Height of tiles in this map. */ - function TilemapLayer(game, parent, key, mapFormat, name, tileWidth, tileHeight) { + function TilemapLayer(parent, id, key, mapFormat, name, tileWidth, tileHeight) { /** * Controls whether update() and draw() are automatically called. * @type {boolean} @@ -11572,8 +11572,9 @@ var Phaser; * @type {number} */ this.tileSpacing = 0; - this.game = game; this.parent = parent; + this.game = parent.game; + this.ID = id; this.name = name; this.mapFormat = mapFormat; this.tileWidth = tileWidth; @@ -12028,10 +12029,6 @@ var Phaser; if (typeof tileWidth === "undefined") { tileWidth = 0; } if (typeof tileHeight === "undefined") { tileHeight = 0; } /** - * The Events component - */ - //public events: Phaser.Components.Sprite.Events; - /** * z order value of the object. */ this.z = -1; @@ -12072,17 +12069,6 @@ var Phaser; } Tilemap.FORMAT_CSV = 0; Tilemap.FORMAT_TILED_JSON = 1; - Tilemap.prototype.preUpdate = /** - * Inherited methods for overriding. - */ - function () { - }; - Tilemap.prototype.update = function () { - }; - Tilemap.prototype.postUpdate = function () { - }; - Tilemap.prototype.destroy = function () { - }; Tilemap.prototype.parseCSV = /** * Parset csv map data and generate tiles. * @param data {string} CSV map data. @@ -12091,7 +12077,7 @@ var Phaser; * @param tileHeight {number} Height of its tile. */ function (data, key, tileWidth, tileHeight) { - var layer = new Phaser.TilemapLayer(this.game, this, key, Tilemap.FORMAT_CSV, 'TileLayerCSV' + this.layers.length.toString(), tileWidth, tileHeight); + var layer = new Phaser.TilemapLayer(this, 0, key, Tilemap.FORMAT_CSV, 'TileLayerCSV' + this.layers.length.toString(), tileWidth, tileHeight); // Trim any rogue whitespace from the data data = data.trim(); var rows = data.split("\n"); @@ -12118,7 +12104,7 @@ var Phaser; data = data.trim(); var json = JSON.parse(data); for(var i = 0; i < json.layers.length; i++) { - var layer = new Phaser.TilemapLayer(this.game, this, key, Tilemap.FORMAT_TILED_JSON, json.layers[i].name, json.tilewidth, json.tileheight); + var layer = new Phaser.TilemapLayer(this, i, key, Tilemap.FORMAT_TILED_JSON, json.layers[i].name, json.tilewidth, json.tileheight); // Check it's a data layer if(!json.layers[i].data) { continue; @@ -12236,7 +12222,7 @@ var Phaser; * @return {Tile} The tile with specific properties. */ function (x, y, layer) { - if (typeof layer === "undefined") { layer = 0; } + if (typeof layer === "undefined") { layer = this.currentLayer.ID; } return this.tiles[this.layers[layer].getTileIndex(x, y)]; }; Tilemap.prototype.getTileFromWorldXY = /** @@ -12247,7 +12233,7 @@ var Phaser; * @return {Tile} The tile with specific properties. */ function (x, y, layer) { - if (typeof layer === "undefined") { layer = 0; } + if (typeof layer === "undefined") { layer = this.currentLayer.ID; } return this.tiles[this.layers[layer].getTileFromWorldXY(x, y)]; }; Tilemap.prototype.getTileFromInputXY = /** @@ -12256,7 +12242,7 @@ var Phaser; * @returns {Tile} */ function (layer) { - if (typeof layer === "undefined") { layer = 0; } + if (typeof layer === "undefined") { layer = this.currentLayer.ID; } return this.tiles[this.layers[layer].getTileFromWorldXY(this.game.input.worldX, this.game.input.worldY)]; }; Tilemap.prototype.getTileOverlaps = /** @@ -12317,17 +12303,19 @@ var Phaser; * @param [layer] {number} which layer you want to set the tile to. */ function (x, y, index, layer) { - if (typeof layer === "undefined") { layer = 0; } + if (typeof layer === "undefined") { layer = this.currentLayer.ID; } this.layers[layer].putTile(x, y, index); }; + Tilemap.prototype.destroy = function () { + this.texture = null; + this.transform = null; + this.tiles.length = 0; + this.layers.length = 0; + }; return Tilemap; })(); Phaser.Tilemap = Tilemap; - // Set current layer - // Set layer order? - // Delete tiles of certain type - // Erase tiles - })(Phaser || (Phaser = {})); +})(Phaser || (Phaser = {})); /// /// /// @@ -18011,20 +17999,21 @@ var Phaser; function TilemapRenderer(game) { // Local rendering related temp vars to help avoid gc spikes through constant var creation this._ga = 1; - this._sx = 0; - this._sy = 0; - this._sw = 0; - this._sh = 0; + //private _sx: number = 0; + //private _sy: number = 0; + //private _sw: number = 0; + //private _sh: number = 0; this._dx = 0; this._dy = 0; this._dw = 0; this._dh = 0; - this._fx = 1; - this._fy = 1; + //private _fx: number = 1; + //private _fy: number = 1; this._tx = 0; this._ty = 0; - this._sin = 0; - this._cos = 1; + this._tl = 0; + //private _sin: number = 0; + //private _cos: number = 1; this._maxX = 0; this._maxY = 0; this._startX = 0; @@ -18037,11 +18026,12 @@ var Phaser; */ function (camera, tilemap) { // Loop through the layers - for(var i = 0; i < tilemap.layers.length; i++) { - var layer = tilemap.layers[i]; - if(layer.visible == false || layer.alpha < 0.1) { + this._tl = tilemap.layers.length; + for(var i = 0; i < this._tl; i++) { + if(tilemap.layers[i].visible == false || tilemap.layers[i].alpha < 0.1) { continue; } + var layer = tilemap.layers[i]; // Work out how many tiles we can fit into our camera and round it up for the edges this._maxX = this.game.math.ceil(camera.width / layer.tileWidth) + 1; this._maxY = this.game.math.ceil(camera.height / layer.tileHeight) + 1;