diff --git a/src/gameobjects/tilemap/dynamiclayer/DynamicTilemapLayer.js b/src/gameobjects/tilemap/dynamiclayer/DynamicTilemapLayer.js index 12a351188..8e6675748 100644 --- a/src/gameobjects/tilemap/dynamiclayer/DynamicTilemapLayer.js +++ b/src/gameobjects/tilemap/dynamiclayer/DynamicTilemapLayer.js @@ -17,7 +17,6 @@ var DynamicTilemapLayer = new Class({ Components.RenderTarget, Components.ScaleMode, Components.Size, - Components.Texture, Components.Transform, Components.Visible, Components.ScrollFactor, @@ -90,9 +89,7 @@ var DynamicTilemapLayer = new Class({ this.culledTiles = []; this.setAlpha(this.layer.alpha); - this.setTexture(tileset.image.key); this.setPosition(x, y); - this.setSizeToFrame(); this.setOrigin(); this.setSize(this.layer.tileWidth * this.layer.width, this.layer.tileHeight * this.layer.height); }, diff --git a/src/gameobjects/tilemap/dynamiclayer/DynamicTilemapLayerCanvasRenderer.js b/src/gameobjects/tilemap/dynamiclayer/DynamicTilemapLayerCanvasRenderer.js index f4e80e87f..cb304ed5c 100644 --- a/src/gameobjects/tilemap/dynamiclayer/DynamicTilemapLayerCanvasRenderer.js +++ b/src/gameobjects/tilemap/dynamiclayer/DynamicTilemapLayerCanvasRenderer.js @@ -11,7 +11,7 @@ var DynamicTilemapLayerCanvasRenderer = function (renderer, gameObject, interpol var renderTiles = gameObject.culledTiles; var length = renderTiles.length; - var image = gameObject.frame.source.image; + var image = gameObject.tileset.image.getSourceImage(); var tileset = this.tileset; var tx = gameObject.x - camera.scrollX * gameObject.scrollFactorX; diff --git a/src/gameobjects/tilemap/dynamiclayer/DynamicTilemapLayerWebGLRenderer.js b/src/gameobjects/tilemap/dynamiclayer/DynamicTilemapLayerWebGLRenderer.js index bd5cb8001..eaf65a97d 100644 --- a/src/gameobjects/tilemap/dynamiclayer/DynamicTilemapLayerWebGLRenderer.js +++ b/src/gameobjects/tilemap/dynamiclayer/DynamicTilemapLayerWebGLRenderer.js @@ -12,7 +12,7 @@ var DynamicTilemapLayerWebGLRenderer = function (renderer, gameObject, interpola var renderTiles = gameObject.culledTiles; var length = renderTiles.length; var batch = renderer.spriteBatch; - var texture = gameObject.texture.source[0].glTexture; + var texture = gameObject.tileset.image.get().source.glTexture; var textureWidth = texture.width; var textureHeight = texture.height; var tileset = this.tileset; diff --git a/src/gameobjects/tilemap/staticlayer/StaticTilemapLayer.js b/src/gameobjects/tilemap/staticlayer/StaticTilemapLayer.js index 442e67c37..7a5397ce8 100644 --- a/src/gameobjects/tilemap/staticlayer/StaticTilemapLayer.js +++ b/src/gameobjects/tilemap/staticlayer/StaticTilemapLayer.js @@ -18,7 +18,6 @@ var StaticTilemapLayer = new Class({ Components.RenderTarget, Components.ScaleMode, Components.Size, - Components.Texture, Components.Transform, Components.Visible, Components.ScrollFactor, @@ -99,9 +98,7 @@ var StaticTilemapLayer = new Class({ this.vertexCount = 0; this.setAlpha(this.layer.alpha); - this.setTexture(tileset.image.key); this.setPosition(x, y); - this.setSizeToFrame(); this.setOrigin(); this.setSize(this.layer.tileWidth * this.layer.width, this.layer.tileHeight * this.layer.height); @@ -113,7 +110,6 @@ var StaticTilemapLayer = new Class({ */ contextRestore: function (renderer) { - this.tileTexture = null; this.dirty = true; this.vbo = null; this.gl = renderer.gl; @@ -131,8 +127,8 @@ var StaticTilemapLayer = new Class({ var tileset = this.tileset; var mapWidth = this.layer.width; var mapHeight = this.layer.height; - var width = this.texture.source[0].width; - var height = this.texture.source[0].height; + var width = tileset.image.get().width; + var height = tileset.image.get().height; var mapData = this.layer.data; var tile; diff --git a/src/gameobjects/tilemap/staticlayer/StaticTilemapLayerCanvasRenderer.js b/src/gameobjects/tilemap/staticlayer/StaticTilemapLayerCanvasRenderer.js index de99a6b03..df394ba3d 100644 --- a/src/gameobjects/tilemap/staticlayer/StaticTilemapLayerCanvasRenderer.js +++ b/src/gameobjects/tilemap/staticlayer/StaticTilemapLayerCanvasRenderer.js @@ -12,10 +12,9 @@ var StaticTilemapLayerCanvasRenderer = function (renderer, gameObject, interpola var renderTiles = gameObject.culledTiles; var tileset = this.tileset; - var frame = gameObject.frame; var ctx = renderer.gameContext; var tileCount = renderTiles.length; - var image = frame.source.image; + var image = tileset.image.getSourceImage(); var tx = gameObject.x - camera.scrollX * gameObject.scrollFactorX; var ty = gameObject.y - camera.scrollY * gameObject.scrollFactorY; diff --git a/src/gameobjects/tilemap/staticlayer/StaticTilemapLayerWebGLRenderer.js b/src/gameobjects/tilemap/staticlayer/StaticTilemapLayerWebGLRenderer.js index 5c7b09c42..6531ffd88 100644 --- a/src/gameobjects/tilemap/staticlayer/StaticTilemapLayerWebGLRenderer.js +++ b/src/gameobjects/tilemap/staticlayer/StaticTilemapLayerWebGLRenderer.js @@ -8,10 +8,10 @@ var StaticTilemapLayerWebGLRenderer = function (renderer, src, interpolationPerc } var gameObject = src; - var frame = gameObject.frame; var gl = gameObject.gl; + var frame = gameObject.tileset.image.get(); - renderer.setRenderer(gameObject.tilemapRenderer, frame.texture.source[frame.sourceIndex].glTexture, gameObject.renderTarget); + renderer.setRenderer(gameObject.tilemapRenderer, frame.source.glTexture, gameObject.renderTarget); gameObject.tilemapRenderer.bind(); gameObject.upload(camera); diff --git a/src/physics/arcade/inc/tilemap/SeparateTile.js b/src/physics/arcade/inc/tilemap/SeparateTile.js index 2ea374933..79ceb8d61 100644 --- a/src/physics/arcade/inc/tilemap/SeparateTile.js +++ b/src/physics/arcade/inc/tilemap/SeparateTile.js @@ -55,7 +55,7 @@ var SeparateTile = function (i, body, tile, tileWorldRect, tilemapLayer, tileBia { if (faceHorizontal) { - ox = TileCheckX(body, tile, tilemapLayer, tileBias); + ox = TileCheckX(body, tile, tileLeft, tileRight, tileBias); // That's horizontal done, check if we still intersects? If not then we can return now if (ox !== 0 && !TileIntersectsBody(tileWorldRect, body)) @@ -66,14 +66,14 @@ var SeparateTile = function (i, body, tile, tileWorldRect, tilemapLayer, tileBia if (faceVertical) { - oy = TileCheckY(body, tile, tilemapLayer, tileBias); + oy = TileCheckY(body, tile, tileTop, tileBottom, tileBias); } } else { if (faceVertical) { - oy = TileCheckY(body, tile, tilemapLayer, tileBias); + oy = TileCheckY(body, tile, tileTop, tileBottom, tileBias); // That's vertical done, check if we still intersects? If not then we can return now if (oy !== 0 && !TileIntersectsBody(tileWorldRect, body)) @@ -84,7 +84,7 @@ var SeparateTile = function (i, body, tile, tileWorldRect, tilemapLayer, tileBia if (faceHorizontal) { - ox = TileCheckX(body, tile, tilemapLayer, tileBias); + ox = TileCheckX(body, tile, tileLeft, tileRight, tileBias); } } diff --git a/src/physics/arcade/inc/tilemap/TileCheckX.js b/src/physics/arcade/inc/tilemap/TileCheckX.js index 92258db5e..2e5a3cc18 100644 --- a/src/physics/arcade/inc/tilemap/TileCheckX.js +++ b/src/physics/arcade/inc/tilemap/TileCheckX.js @@ -10,12 +10,9 @@ var ProcessTileSeparationX = require('./ProcessTileSeparationX'); * @param {Phaser.TilemapLayer} tilemapLayer - The tilemapLayer to collide against. * @return {number} The amount of separation that occurred. */ -var TileCheckX = function (body, tile, tilemapLayer, tileBias) +var TileCheckX = function (body, tile, tileLeft, tileRight, tileBias) { var ox = 0; - var tileLeft = tilemapLayer.tileToWorldX(tile.x); - var tileWidth = tile.width * tilemapLayer.scaleX; - var tileRight = tileLeft + tileWidth; if (body.deltaX() < 0 && !body.blocked.left && tile.collideRight && body.checkCollision.left) { diff --git a/src/physics/arcade/inc/tilemap/TileCheckY.js b/src/physics/arcade/inc/tilemap/TileCheckY.js index 282a20aca..3bcfea7e4 100644 --- a/src/physics/arcade/inc/tilemap/TileCheckY.js +++ b/src/physics/arcade/inc/tilemap/TileCheckY.js @@ -10,12 +10,9 @@ var ProcessTileSeparationY = require('./ProcessTileSeparationY'); * @param {Phaser.TilemapLayer} tilemapLayer - The tilemapLayer to collide against. * @return {number} The amount of separation that occurred. */ -var TileCheckY = function (body, tile, tilemapLayer, tileBias) +var TileCheckY = function (body, tile, tileTop, tileBottom, tileBias) { var oy = 0; - var tileTop = tilemapLayer.tileToWorldX(tile.y); - var tileHeight = tile.height * tilemapLayer.scaleY; - var tileBottom = tileTop + tileHeight; if (body.deltaY() < 0 && !body.blocked.up && tile.collideDown && body.checkCollision.up) {