Skip to content

Commit 91b9513

Browse files
committed
TilemapLayer.getTileX, getTileY and getTileXY all now required a Phaser.TilemapLayer (or Phaser.TilemapLayerGL) as the first argument.
Tilemap.getRayCastTiles now requires a Phaser.TilemapLayer (or Phaser.TilemapLayerGL) as the first argument. Tilemap.getTiles now requires a Phaser.TilemapLayer (or Phaser.TilemapLayerGL) as the first argument.
1 parent 0301330 commit 91b9513

2 files changed

Lines changed: 22 additions & 33 deletions

File tree

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -326,11 +326,14 @@ You can read all about the philosophy behind Lazer [here](http://phaser.io/news/
326326
* The Loader.headers object has a new property `requestedWith`. By default this is set to `false`, but it can be used to set the `X-Requested-With` header to `XMLHttpRequest` (or any other value you need). To enable this do `this.load.headers.requestedWith = 'XMLHttpRequest'` before adding anything to the Loader.
327327
* ScaleManager.hasPhaserSetFullScreen is a new boolean that identifies if the browser is in full screen mode or not, and if Phaser was the one that requested it. As it's possible to enter full screen mode outside of Phaser, and it then gets confused about what bounding parent to use.
328328
* Phaser.Tileset has a new property `lastgid` which is populated automatically by the TilemapParser when importing Tiled map data, or can be set manually if building your own tileset.
329-
* TilemapLayer.getRayCastTiles has been moved to Tilemap.getRayCastTiles.
330329
* TilemapLayer.rayStepRate has been moved to Tilemap.rayStepRate.
330+
* TilemapLayer.getRayCastTiles has been moved to Tilemap.getRayCastTiles.
331331
* TilemapLayer.getTiles has been moved to Tilemap.getTiles.
332-
* The private methods `TilemapLayer._fixX`, `_unfixX`, `_fixY` and `_unfixY` have been moved to `Tilemap.
333-
* TilemapLayer.getTileX, getTileY and getTileXY have been moved to Tilemap, and work off the current layer.
332+
* The private methods `TilemapLayer._fixX`, `_unfixX`, `_fixY` and `_unfixY` have been moved to the Tilemap class.
333+
* TilemapLayer.getTileX, getTileY and getTileXY have been moved to the Tilemap class.
334+
* TilemapLayer.getTileX, getTileY and getTileXY all now required a Phaser.TilemapLayer (or Phaser.TilemapLayerGL) as the first argument.
335+
* Tilemap.getRayCastTiles now requires a Phaser.TilemapLayer (or Phaser.TilemapLayerGL) as the first argument.
336+
* Tilemap.getTiles now requires a Phaser.TilemapLayer (or Phaser.TilemapLayerGL) as the first argument.
334337

335338
### Bug Fixes
336339

src/tilemap/Tilemap.js

Lines changed: 16 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2000,14 +2000,14 @@ Phaser.Tilemap.prototype = {
20002000
* @param {boolean} [interestingFace=false] - If true, _only_ return tiles that have interesting faces.
20012001
* @return {Phaser.Tile[]} An array of Phaser.Tiles.
20022002
*/
2003-
getRayCastTiles: function (line, stepRate, collides, interestingFace) {
2003+
getRayCastTiles: function (layer, line, stepRate, collides, interestingFace) {
20042004

20052005
if (!stepRate) { stepRate = this.rayStepRate; }
20062006
if (collides === undefined) { collides = false; }
20072007
if (interestingFace === undefined) { interestingFace = false; }
20082008

20092009
// First get all tiles that touch the bounds of the line
2010-
var tiles = this.getTiles(line.x, line.y, line.width, line.height, collides, interestingFace);
2010+
var tiles = this.getTiles(layer, line.x, line.y, line.width, line.height, collides, interestingFace);
20112011

20122012
if (tiles.length === 0)
20132013
{
@@ -2054,7 +2054,7 @@ Phaser.Tilemap.prototype = {
20542054
* @param {boolean} [interestingFace=false] - If true, _only_ return tiles that have interesting faces.
20552055
* @return {array<Phaser.Tile>} An array of Tiles.
20562056
*/
2057-
getTiles: function (x, y, width, height, collides, interestingFace) {
2057+
getTiles: function (layer, x, y, width, height, collides, interestingFace) {
20582058

20592059
// Should we only get tiles that have at least one of their collision flags set? (true = yes, false = no just get them all)
20602060

@@ -2063,11 +2063,9 @@ Phaser.Tilemap.prototype = {
20632063

20642064
var fetchAll = !(collides || interestingFace);
20652065

2066-
var layer = this.layer;
2067-
20682066
// Adjust the x,y coordinates for scrollFactor
2069-
x = layer._fixX(x);
2070-
y = layer._fixY(y);
2067+
x = layer._fixX(layer, x);
2068+
y = layer._fixY(layer, y);
20712069

20722070
// Convert the pixel values into tile coordinates
20732071
var tx = Math.floor(x / (layer._mc.cw * layer.scale.x));
@@ -2107,9 +2105,7 @@ Phaser.Tilemap.prototype = {
21072105
* @param {number} x - x coordinate in camera space
21082106
* @return {number} x coordinate in scrollFactor-adjusted dimensions
21092107
*/
2110-
_fixX: function (x) {
2111-
2112-
var layer = this.layer;
2108+
_fixX: function (layer, x) {
21132109

21142110
if (layer.scrollFactorX === 1 || (layer.scrollFactorX === 0 && layer.position.x === 0))
21152111
{
@@ -2134,9 +2130,7 @@ Phaser.Tilemap.prototype = {
21342130
* @param {number} x - x coordinate in scrollFactor-adjusted dimensions
21352131
* @return {number} x coordinate in camera space
21362132
*/
2137-
_unfixX: function (x) {
2138-
2139-
var layer = this.layer;
2133+
_unfixX: function (layer, x) {
21402134

21412135
if (layer.scrollFactorX === 1)
21422136
{
@@ -2155,9 +2149,7 @@ Phaser.Tilemap.prototype = {
21552149
* @param {number} y - y coordinate in camera space
21562150
* @return {number} y coordinate in scrollFactor-adjusted dimensions
21572151
*/
2158-
_fixY: function (y) {
2159-
2160-
var layer = this.layer;
2152+
_fixY: function (layer, y) {
21612153

21622154
if (layer.scrollFactorY === 1 || (layer.scrollFactorY === 0 && layer.position.y === 0))
21632155
{
@@ -2182,9 +2174,7 @@ Phaser.Tilemap.prototype = {
21822174
* @param {number} y - y coordinate in scrollFactor-adjusted dimensions
21832175
* @return {number} y coordinate in camera space
21842176
*/
2185-
_unfixY: function (y) {
2186-
2187-
var layer = this.layer;
2177+
_unfixY: function (layer, y) {
21882178

21892179
if (layer.scrollFactorY === 1)
21902180
{
@@ -2202,11 +2192,9 @@ Phaser.Tilemap.prototype = {
22022192
* @param {number} x - X position of the point in target tile (in pixels).
22032193
* @return {integer} The X map location of the tile.
22042194
*/
2205-
getTileX: function (x) {
2206-
2207-
var layer = this.layer;
2195+
getTileX: function (layer, x) {
22082196

2209-
return Math.floor(this._fixX(x) / layer._mc.tileWidth);
2197+
return Math.floor(this._fixX(layer, x) / layer._mc.tileWidth);
22102198

22112199
},
22122200

@@ -2217,11 +2205,9 @@ Phaser.Tilemap.prototype = {
22172205
* @param {number} y - Y position of the point in target tile (in pixels).
22182206
* @return {integer} The Y map location of the tile.
22192207
*/
2220-
getTileY: function (y) {
2221-
2222-
var layer = this.layer;
2208+
getTileY: function (layer, y) {
22232209

2224-
return Math.floor(this._fixY(y) / layer._mc.tileHeight);
2210+
return Math.floor(this._fixY(layer, y) / layer._mc.tileHeight);
22252211

22262212
},
22272213

@@ -2234,10 +2220,10 @@ Phaser.Tilemap.prototype = {
22342220
* @param {(Phaser.Point|object)} point - The Point/object to update.
22352221
* @return {(Phaser.Point|object)} A Point/object with its `x` and `y` properties set.
22362222
*/
2237-
getTileXY: function (x, y, point) {
2223+
getTileXY: function (layer, x, y, point) {
22382224

2239-
point.x = this.getTileX(x);
2240-
point.y = this.getTileY(y);
2225+
point.x = this.getTileX(layer, x);
2226+
point.y = this.getTileY(layer, y);
22412227

22422228
return point;
22432229

0 commit comments

Comments
 (0)