Skip to content

Commit 1a88ff9

Browse files
committed
updated dynamic layer and tilemap
1 parent f17aef0 commit 1a88ff9

4 files changed

Lines changed: 14 additions & 26 deletions

File tree

src/tilemaps/Tilemap.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2345,7 +2345,7 @@ var Tilemap = new Class({
23452345

23462346
if (layer === null) { return null; }
23472347

2348-
return TilemapComponents.TileToWorldX(tileX, camera, layer);
2348+
return TilemapComponents.TileToWorldX(tileX, camera, layer, this.orientation);
23492349
},
23502350

23512351
/**
@@ -2370,7 +2370,7 @@ var Tilemap = new Class({
23702370

23712371
if (layer === null) { return null; }
23722372

2373-
return TilemapComponents.TileToWorldY(tileX, camera, layer);
2373+
return TilemapComponents.TileToWorldY(tileX, camera, layer, this.orientation);
23742374
},
23752375

23762376
/**
@@ -2397,7 +2397,7 @@ var Tilemap = new Class({
23972397

23982398
if (layer === null) { return null; }
23992399

2400-
return TilemapComponents.TileToWorldXY(tileX, tileY, point, camera, layer);
2400+
return TilemapComponents.TileToWorldXY(tileX, tileY, point, camera, layer, this.orientation);
24012401
},
24022402

24032403
/**
@@ -2468,7 +2468,7 @@ var Tilemap = new Class({
24682468

24692469
if (layer === null) { return null; }
24702470

2471-
return TilemapComponents.WorldToTileX(worldX, snapToFloor, camera, layer);
2471+
return TilemapComponents.WorldToTileX(worldX, snapToFloor, camera, layer, this.orientation);
24722472
},
24732473

24742474
/**
@@ -2493,7 +2493,7 @@ var Tilemap = new Class({
24932493

24942494
if (layer === null) { return null; }
24952495

2496-
return TilemapComponents.WorldToTileY(worldY, snapToFloor, camera, layer);
2496+
return TilemapComponents.WorldToTileY(worldY, snapToFloor, camera, layer,this.orientation);
24972497
},
24982498

24992499
/**
@@ -2521,7 +2521,7 @@ var Tilemap = new Class({
25212521

25222522
if (layer === null) { return null; }
25232523

2524-
return TilemapComponents.WorldToTileXY(worldX, worldY, snapToFloor, point, camera, layer);
2524+
return TilemapComponents.WorldToTileXY(worldX, worldY, snapToFloor, point, camera, layer, this.orientation);
25252525
},
25262526

25272527
/**

src/tilemaps/components/TileToWorldY.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ var TileToWorldY = function (tileY, camera, layer)
2828
if (tilemapLayer)
2929
{
3030
if (camera === undefined) { camera = tilemapLayer.scene.cameras.main; }
31-
3231
layerWorldY = (tilemapLayer.y + camera.scrollY * (1 - tilemapLayer.scrollFactorY));
33-
3432
tileHeight *= tilemapLayer.scaleY;
3533
}
3634

src/tilemaps/components/WorldToTileX.js

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,11 @@ var WorldToTileX = function (worldX, snapToFloor, camera, layer, orientation)
2727
if (snapToFloor === undefined) { snapToFloor = true; }
2828

2929
var tileWidth = layer.baseTileWidth;
30-
var tileHeight = layer.baseTileHeight;
3130
var tilemapLayer = layer.tilemapLayer;
3231

3332
if (tilemapLayer)
3433
{
3534
if (camera === undefined) { camera = tilemapLayer.scene.cameras.main; }
36-
37-
// Find the world position relative to the static or dynamic layer's top left origin,
38-
// factoring in the camera's vertical scroll
39-
worldY = worldY - (tilemapLayer.y + camera.scrollY * (1 - tilemapLayer.scrollFactorY));
40-
41-
tileHeight *= tilemapLayer.scaleY;
42-
4335
// Find the world position relative to the static or dynamic layer's top left origin,
4436
// factoring in the camera's horizontal scroll
4537
worldX = worldX - (tilemapLayer.x + camera.scrollX * (1 - tilemapLayer.scrollFactorX));
@@ -52,10 +44,8 @@ var WorldToTileX = function (worldX, snapToFloor, camera, layer, orientation)
5244
? Math.floor(worldX / tileWidth)
5345
: worldX / tileWidth;
5446
} else if (orientation === "isometric") {
55-
return snapToFloor
56-
? Math.floor((worldX/(tileWidth/2) + worldY/(tileHeight/2))/2)
57-
: ((worldX/(tileWidth/2) + worldY/(tileHeight/2))/2);
58-
47+
console.warn('With isometric map types you have to use the WorldToTileXY function.');
48+
return null
5949
}
6050

6151
};

src/tilemaps/dynamiclayer/DynamicTilemapLayer.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1178,7 +1178,7 @@ var DynamicTilemapLayer = new Class({
11781178
*/
11791179
tileToWorldX: function (tileX, camera)
11801180
{
1181-
return TilemapComponents.TileToWorldX(tileX, camera, this.layer);
1181+
return TilemapComponents.TileToWorldX(tileX, camera, this.layer, this.tilemap.orientation);
11821182
},
11831183

11841184
/**
@@ -1195,7 +1195,7 @@ var DynamicTilemapLayer = new Class({
11951195
*/
11961196
tileToWorldY: function (tileY, camera)
11971197
{
1198-
return TilemapComponents.TileToWorldY(tileY, camera, this.layer);
1198+
return TilemapComponents.TileToWorldY(tileY, camera, this.layer, this.tilemap.orientation);
11991199
},
12001200

12011201
/**
@@ -1215,7 +1215,7 @@ var DynamicTilemapLayer = new Class({
12151215
*/
12161216
tileToWorldXY: function (tileX, tileY, point, camera)
12171217
{
1218-
return TilemapComponents.TileToWorldXY(tileX, tileY, point, camera, this.layer);
1218+
return TilemapComponents.TileToWorldXY(tileX, tileY, point, camera, this.layer, this.tilemap.orientation);
12191219
},
12201220

12211221
/**
@@ -1268,7 +1268,7 @@ var DynamicTilemapLayer = new Class({
12681268
*/
12691269
worldToTileX: function (worldX, snapToFloor, camera)
12701270
{
1271-
return TilemapComponents.WorldToTileX(worldX, snapToFloor, camera, this.layer);
1271+
return TilemapComponents.WorldToTileX(worldX, snapToFloor, camera, this.layer, this.tilemap.orientation);
12721272
},
12731273

12741274
/**
@@ -1286,7 +1286,7 @@ var DynamicTilemapLayer = new Class({
12861286
*/
12871287
worldToTileY: function (worldY, snapToFloor, camera)
12881288
{
1289-
return TilemapComponents.WorldToTileY(worldY, snapToFloor, camera, this.layer);
1289+
return TilemapComponents.WorldToTileY(worldY, snapToFloor, camera, this.layer, this.tilemap.orientation);
12901290
},
12911291

12921292
/**
@@ -1307,7 +1307,7 @@ var DynamicTilemapLayer = new Class({
13071307
*/
13081308
worldToTileXY: function (worldX, worldY, snapToFloor, point, camera)
13091309
{
1310-
return TilemapComponents.WorldToTileXY(worldX, worldY, snapToFloor, point, camera, this.layer);
1310+
return TilemapComponents.WorldToTileXY(worldX, worldY, snapToFloor, point, camera, this.layer, this.tilemap.orientation);
13111311
}
13121312

13131313
});

0 commit comments

Comments
 (0)