Skip to content

Commit 050325b

Browse files
committed
tried to pin down where the orientation became undefined, no success.
1 parent f1e1ab1 commit 050325b

9 files changed

Lines changed: 382078 additions & 15 deletions

File tree

dist/phaser-arcade-physics.js

Lines changed: 179879 additions & 0 deletions
Large diffs are not rendered by default.

dist/phaser-arcade-physics.min.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/phaser.js

Lines changed: 202165 additions & 0 deletions
Large diffs are not rendered by default.

dist/phaser.min.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/tilemaps/Tile.js

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,9 @@ var Tile = new Class({
4848

4949
initialize:
5050

51-
function Tile (layer, index, x, y, width, height, baseWidth, baseHeight, orientation)
51+
function Tile (layer, index, x, y, width, height, orientation, baseWidth, baseHeight )
5252
{
53+
console.log(this)
5354
/**
5455
* The LayerData in the Tilemap data that this tile belongs to.
5556
*
@@ -77,7 +78,6 @@ var Tile = new Class({
7778
* @since 3.0.0
7879
*/
7980
this.x = x;
80-
console.log("tile x : " + x)
8181

8282
/**
8383
* The y map coordinate of this tile in tile units.
@@ -114,7 +114,7 @@ var Tile = new Class({
114114
* @type {integer}
115115
* @since 3.0.0
116116
*/
117-
this.baseWidth = (baseWidth !== undefined) ? baseWidth : width;
117+
this.baseWidth = (baseWidth !== undefined && !baseWidth.isNaN()) ? baseWidth : width;
118118

119119
/**
120120
* The map's base height of a tile in pixels. Tiled maps support multiple tileset sizes
@@ -124,7 +124,7 @@ var Tile = new Class({
124124
* @type {integer}
125125
* @since 3.0.0
126126
*/
127-
this.baseHeight = (baseHeight !== undefined) ? baseHeight : height;
127+
this.baseHeight = (baseHeight !== undefined && !baseWidth.isNaN()) ? baseHeight : height;
128128

129129
/**
130130
* The x coordinate of the top left of this tile in pixels. This is relative to the top left
@@ -284,8 +284,10 @@ var Tile = new Class({
284284
* @type {string}
285285
* @since 3.2.PR_svipal
286286
*/
287-
this.orientation = orientation
288-
console.log("tile orientation : "+this.orientation)
287+
// we default to orthogonal
288+
this.orientation = (orientation !== undefined) ? orientation : "orthogonal";
289+
290+
// console.log("tile orientation : "+this.orientation)
289291
},
290292

291293
/**
@@ -721,18 +723,24 @@ var Tile = new Class({
721723
// Tiled places tiles on a grid of baseWidth x baseHeight. The origin for a tile is the
722724
// bottom left, while the Phaser renderer assumes the origin is the top left. The y
723725
// coordinate needs to be adjusted by the difference.
724-
if (this.orientation === "orthogonal" || true) {
726+
console.log("width" + this.baseWidth)
727+
console.log("height" + this.baseHeight)
728+
if (this.orientation === "orthogonal") {
725729
this.pixelX = this.x * this.baseWidth;
726730
this.pixelY = this.y * this.baseHeight;
727731
console.log("orthopix "+this.pixelX+","+this.pixelY)
728-
} else /*if (this.orientation === "isometric")*/ {
729-
732+
} else if (this.orientation === "isometric") {
733+
mapSize = 10
730734
// once we get the 'top' of the losange we need to remove half of the tile width.
731-
this.pixelX = (this.x - this.y) * this.baseWidth *0.5;
735+
this.pixelX = (this.baseWidth/2)*mapSize + (this.x - this.y) * this.baseWidth *0.5;
732736
this.pixelY = (this.x + this.y) * this.baseHeight *0.5;
733737
console.log("isopix "+this.pixelX+","+this.pixelY)
734-
}
735-
738+
console.log(this)
739+
} else {
740+
console.log(this)
741+
console.log("tile orientation : "+this.orientation)
742+
}
743+
736744
// this.pixelY = this.y * this.baseHeight - (this.height - this.baseHeight);
737745

738746
return this;

src/tilemaps/Tilemap.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,8 @@ var Tilemap = new Class({
513513

514514
for (var tileX = 0; tileX < width; tileX++)
515515
{
516-
row.push(new Tile(layerData, -1, tileX, tileY, tileWidth, tileHeight, this.tileWidth, this.tileHeight, this.orientation));
516+
console.log("Tile tm", tileX, tileY, tileWidth, tileHeight, this.orientation, this.tileWidth, this.tileHeight)
517+
row.push(new Tile(layerData, -1, tileX, tileY, tileWidth, tileHeight, this.orientation, this.tileWidth, this.tileHeight));
517518
}
518519

519520
layerData.data.push(row);

src/tilemaps/components/PutTileAtWorldXY.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ var WorldToTileY = require('./WorldToTileY');
2525
* @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values.
2626
* @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon.
2727
* @param {string} orientation - The Tilemap's orientation
28-
* //Instinct : mistake to put it there
28+
*
2929
* @return {Phaser.Tilemaps.Tile} The Tile object that was created or added to this map.
3030
*/
3131
var PutTileAtWorldXY = function (tile, worldX, worldY, recalculateFaces, camera, layer, orientation)

src/tilemaps/parsers/tiled/ParseJSONTiled.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ var ParseJSONTiled = function (name, json, insertNull)
3636
{
3737
console.warn('isometric map types are WIP in this version of Phaser');
3838

39-
} else if (json.orientation == 'orthogonal') {
39+
} else if (json.orientation !== 'orthogonal') {
4040
console.warn('Only orthogonal map types are supported in this version of Phaser');
4141
return null;
4242
}

src/tilemaps/parsers/tiled/ParseTileLayers.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@ var ParseTileLayers = function (json, insertNull)
159159
// index, x, y, width, height
160160
if (gidInfo.gid > 0)
161161
{
162+
console.log("Tile ptl 1", newOffsetX, newOffsetY, json.tilewidth,
163+
json.tileheight,json.orientation)
162164
tile = new Tile(layerData, gidInfo.gid, newOffsetX, newOffsetY, json.tilewidth,
163165
json.tileheight,json.orientation);
164166

@@ -171,6 +173,8 @@ var ParseTileLayers = function (json, insertNull)
171173
}
172174
else
173175
{
176+
console.log("Tile ptl 2", newOffsetX, newOffsetY, json.tilewidth,
177+
json.tileheight,json.orientation)
174178
blankTile = insertNull
175179
? null
176180
: new Tile(layerData, -1, newOffsetX, newOffsetY, json.tilewidth, json.tileheight,json.orientation);
@@ -213,6 +217,8 @@ var ParseTileLayers = function (json, insertNull)
213217
// index, x, y, width, height
214218
if (gidInfo.gid > 0)
215219
{
220+
console.log("Tile ptl 3", newOffsetX, newOffsetY, json.tilewidth,
221+
json.tileheight,json.orientation)
216222
tile = new Tile(layerData, gidInfo.gid, x, output.length, json.tilewidth,
217223
json.tileheight, json.orientation);
218224

@@ -225,6 +231,8 @@ var ParseTileLayers = function (json, insertNull)
225231
}
226232
else
227233
{
234+
console.log("Tile ptl 4", newOffsetX, newOffsetY, json.tilewidth,
235+
json.tileheight,json.orientation)
228236
blankTile = insertNull
229237
? null
230238
: new Tile(layerData, -1, x, output.length, json.tilewidth, json.tileheight, json.orientation);

0 commit comments

Comments
 (0)