tried to pin down where the orientation became undefined, no success.

This commit is contained in:
Svipal 2020-01-29 17:42:39 +01:00
parent f1e1ab1941
commit 050325bff0
9 changed files with 382078 additions and 15 deletions

179879
dist/phaser-arcade-physics.js vendored Normal file

File diff suppressed because it is too large Load diff

1
dist/phaser-arcade-physics.min.js vendored Normal file

File diff suppressed because one or more lines are too long

202165
dist/phaser.js vendored Normal file

File diff suppressed because it is too large Load diff

1
dist/phaser.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View file

@ -48,8 +48,9 @@ var Tile = new Class({
initialize:
function Tile (layer, index, x, y, width, height, baseWidth, baseHeight, orientation)
function Tile (layer, index, x, y, width, height, orientation, baseWidth, baseHeight )
{
console.log(this)
/**
* The LayerData in the Tilemap data that this tile belongs to.
*
@ -77,7 +78,6 @@ var Tile = new Class({
* @since 3.0.0
*/
this.x = x;
console.log("tile x : " + x)
/**
* The y map coordinate of this tile in tile units.
@ -114,7 +114,7 @@ var Tile = new Class({
* @type {integer}
* @since 3.0.0
*/
this.baseWidth = (baseWidth !== undefined) ? baseWidth : width;
this.baseWidth = (baseWidth !== undefined && !baseWidth.isNaN()) ? baseWidth : width;
/**
* The map's base height of a tile in pixels. Tiled maps support multiple tileset sizes
@ -124,7 +124,7 @@ var Tile = new Class({
* @type {integer}
* @since 3.0.0
*/
this.baseHeight = (baseHeight !== undefined) ? baseHeight : height;
this.baseHeight = (baseHeight !== undefined && !baseWidth.isNaN()) ? baseHeight : height;
/**
* 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({
* @type {string}
* @since 3.2.PR_svipal
*/
this.orientation = orientation
console.log("tile orientation : "+this.orientation)
// we default to orthogonal
this.orientation = (orientation !== undefined) ? orientation : "orthogonal";
// console.log("tile orientation : "+this.orientation)
},
/**
@ -721,18 +723,24 @@ var Tile = new Class({
// Tiled places tiles on a grid of baseWidth x baseHeight. The origin for a tile is the
// bottom left, while the Phaser renderer assumes the origin is the top left. The y
// coordinate needs to be adjusted by the difference.
if (this.orientation === "orthogonal" || true) {
console.log("width" + this.baseWidth)
console.log("height" + this.baseHeight)
if (this.orientation === "orthogonal") {
this.pixelX = this.x * this.baseWidth;
this.pixelY = this.y * this.baseHeight;
console.log("orthopix "+this.pixelX+","+this.pixelY)
} else /*if (this.orientation === "isometric")*/ {
} else if (this.orientation === "isometric") {
mapSize = 10
// once we get the 'top' of the losange we need to remove half of the tile width.
this.pixelX = (this.x - this.y) * this.baseWidth *0.5;
this.pixelX = (this.baseWidth/2)*mapSize + (this.x - this.y) * this.baseWidth *0.5;
this.pixelY = (this.x + this.y) * this.baseHeight *0.5;
console.log("isopix "+this.pixelX+","+this.pixelY)
}
console.log(this)
} else {
console.log(this)
console.log("tile orientation : "+this.orientation)
}
// this.pixelY = this.y * this.baseHeight - (this.height - this.baseHeight);
return this;

View file

@ -513,7 +513,8 @@ var Tilemap = new Class({
for (var tileX = 0; tileX < width; tileX++)
{
row.push(new Tile(layerData, -1, tileX, tileY, tileWidth, tileHeight, this.tileWidth, this.tileHeight, this.orientation));
console.log("Tile tm", tileX, tileY, tileWidth, tileHeight, this.orientation, this.tileWidth, this.tileHeight)
row.push(new Tile(layerData, -1, tileX, tileY, tileWidth, tileHeight, this.orientation, this.tileWidth, this.tileHeight));
}
layerData.data.push(row);

View file

@ -25,7 +25,7 @@ var WorldToTileY = require('./WorldToTileY');
* @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values.
* @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon.
* @param {string} orientation - The Tilemap's orientation
* //Instinct : mistake to put it there
*
* @return {Phaser.Tilemaps.Tile} The Tile object that was created or added to this map.
*/
var PutTileAtWorldXY = function (tile, worldX, worldY, recalculateFaces, camera, layer, orientation)

View file

@ -36,7 +36,7 @@ var ParseJSONTiled = function (name, json, insertNull)
{
console.warn('isometric map types are WIP in this version of Phaser');
} else if (json.orientation == 'orthogonal') {
} else if (json.orientation !== 'orthogonal') {
console.warn('Only orthogonal map types are supported in this version of Phaser');
return null;
}

View file

@ -159,6 +159,8 @@ var ParseTileLayers = function (json, insertNull)
// index, x, y, width, height
if (gidInfo.gid > 0)
{
console.log("Tile ptl 1", newOffsetX, newOffsetY, json.tilewidth,
json.tileheight,json.orientation)
tile = new Tile(layerData, gidInfo.gid, newOffsetX, newOffsetY, json.tilewidth,
json.tileheight,json.orientation);
@ -171,6 +173,8 @@ var ParseTileLayers = function (json, insertNull)
}
else
{
console.log("Tile ptl 2", newOffsetX, newOffsetY, json.tilewidth,
json.tileheight,json.orientation)
blankTile = insertNull
? null
: new Tile(layerData, -1, newOffsetX, newOffsetY, json.tilewidth, json.tileheight,json.orientation);
@ -213,6 +217,8 @@ var ParseTileLayers = function (json, insertNull)
// index, x, y, width, height
if (gidInfo.gid > 0)
{
console.log("Tile ptl 3", newOffsetX, newOffsetY, json.tilewidth,
json.tileheight,json.orientation)
tile = new Tile(layerData, gidInfo.gid, x, output.length, json.tilewidth,
json.tileheight, json.orientation);
@ -225,6 +231,8 @@ var ParseTileLayers = function (json, insertNull)
}
else
{
console.log("Tile ptl 4", newOffsetX, newOffsetY, json.tilewidth,
json.tileheight,json.orientation)
blankTile = insertNull
? null
: new Tile(layerData, -1, x, output.length, json.tilewidth, json.tileheight, json.orientation);