added deep copy, doesn't change anything , this.orientation in the tile still bugging

This commit is contained in:
Svipal 2020-01-29 19:01:22 +01:00
parent 050325bff0
commit a82b27ce6f
7 changed files with 74 additions and 57 deletions

View file

@ -12182,9 +12182,9 @@ module.exports = SetTileCollision;
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
var Class = __webpack_require__(0); var Class = __webpack_require__(0);
var Components = __webpack_require__(11); var Components = __webpack_require__(11);
var Rectangle = __webpack_require__(441); var Rectangle = __webpack_require__(441);
/** /**
* @classdesc * @classdesc
@ -12455,7 +12455,7 @@ var Tile = new Class({
* @since 3.0.0 * @since 3.0.0
*/ */
this.physics = {}; this.physics = {};
/** /**
* An empty object where physics-engine specific information (e.g. bodies) may be stored. * An empty object where physics-engine specific information (e.g. bodies) may be stored.
* *
* @name Phaser.Tilemaps.Tile#orientation * @name Phaser.Tilemaps.Tile#orientation
@ -12463,9 +12463,13 @@ var Tile = new Class({
* @since 3.2.PR_svipal * @since 3.2.PR_svipal
*/ */
// we default to orthogonal // we default to orthogonal
this.orientation = (orientation !== undefined) ? orientation : "orthogonal"; // we need to deep copy the string to prevent the orientation later going out of scope
if (orientation == undefined) {
// console.log("tile orientation : "+this.orientation) this.orientation = "orthogonal";
} else {
this.orientation = orientation // (' ' + orientation).slice(1)
}
console.log("tile orientation : "+this.orientation)
}, },
/** /**
@ -12898,25 +12902,23 @@ var Tile = new Class({
*/ */
updatePixelXY: function () updatePixelXY: function ()
{ {
// Tiled places tiles on a grid of baseWidth x baseHeight. The origin for a tile is the if (orientation === "orthogonal") {
// bottom left, while the Phaser renderer assumes the origin is the top left. The y // In orthogonal mode, Tiled places tiles on a grid of baseWidth x baseHeight. The origin for a tile is the
// coordinate needs to be adjusted by the difference. // bottom left, while the Phaser renderer assumes the origin is the top left. The y
console.log("width" + this.baseWidth) // coordinate needs to be adjusted by the difference.
console.log("height" + this.baseHeight)
if (this.orientation === "orthogonal") {
this.pixelX = this.x * this.baseWidth; this.pixelX = this.x * this.baseWidth;
this.pixelY = this.y * this.baseHeight; this.pixelY = this.y * this.baseHeight;
console.log("orthopix "+this.pixelX+","+this.pixelY) console.log("orthopix "+this.pixelX+","+this.pixelY)
} else if (this.orientation === "isometric") { } else if (orientation === "isometric" ) {
mapSize = 10 mapSize = 10
// once we get the 'top' of the losange we need to remove half of the tile width. // once we get the 'top' of the losange we need to remove half of the tile width.
this.pixelX = (this.baseWidth/2)*mapSize + (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; this.pixelY = (this.x + this.y) * this.baseHeight *0.5;
console.log("isopix "+this.pixelX+","+this.pixelY) console.log("isopix "+this.pixelX+","+this.pixelY)
console.log(this) console.log(self)
} else { } else {
console.log(this) console.log("self :" + self)
console.log("tile orientation : "+this.orientation) console.log("tile orientation 2: "+orientation)
} }
// this.pixelY = this.y * this.baseHeight - (this.height - this.baseHeight); // this.pixelY = this.y * this.baseHeight - (this.height - this.baseHeight);
@ -102924,6 +102926,8 @@ var ParseTileLayers = function (json, insertNull)
// index, x, y, width, height // index, x, y, width, height
if (gidInfo.gid > 0) 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, tile = new Tile(layerData, gidInfo.gid, newOffsetX, newOffsetY, json.tilewidth,
json.tileheight,json.orientation); json.tileheight,json.orientation);
@ -102936,6 +102940,8 @@ var ParseTileLayers = function (json, insertNull)
} }
else else
{ {
console.log("Tile ptl 2", newOffsetX, newOffsetY, json.tilewidth,
json.tileheight,json.orientation)
blankTile = insertNull blankTile = insertNull
? null ? null
: new Tile(layerData, -1, newOffsetX, newOffsetY, json.tilewidth, json.tileheight,json.orientation); : new Tile(layerData, -1, newOffsetX, newOffsetY, json.tilewidth, json.tileheight,json.orientation);
@ -102978,6 +102984,8 @@ var ParseTileLayers = function (json, insertNull)
// index, x, y, width, height // index, x, y, width, height
if (gidInfo.gid > 0) 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, tile = new Tile(layerData, gidInfo.gid, x, output.length, json.tilewidth,
json.tileheight, json.orientation); json.tileheight, json.orientation);
@ -102990,6 +102998,8 @@ var ParseTileLayers = function (json, insertNull)
} }
else else
{ {
console.log("Tile ptl 4", newOffsetX, newOffsetY, json.tilewidth,
json.tileheight,json.orientation)
blankTile = insertNull blankTile = insertNull
? null ? null
: new Tile(layerData, -1, x, output.length, json.tilewidth, json.tileheight, json.orientation); : new Tile(layerData, -1, x, output.length, json.tilewidth, json.tileheight, json.orientation);
@ -104621,7 +104631,7 @@ var Tilemap = new Class({
for (var tileX = 0; tileX < width; tileX++) for (var tileX = 0; tileX < width; tileX++)
{ {
console.log("Tile tm", 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)); row.push(new Tile(layerData, -1, tileX, tileY, tileWidth, tileHeight, this.orientation, this.tileWidth, this.tileHeight));
} }
@ -177177,7 +177187,6 @@ module.exports = {
*/ */
var StaticTilemapLayerWebGLRenderer = function (renderer, src, interpolationPercentage, camera) var StaticTilemapLayerWebGLRenderer = function (renderer, src, interpolationPercentage, camera)
{ {
console.log("webgl renderer")
var tilesets = src.tileset; var tilesets = src.tileset;
var pipeline = src.pipeline; var pipeline = src.pipeline;
@ -177249,7 +177258,6 @@ module.exports = StaticTilemapLayerWebGLRenderer;
var StaticTilemapLayerCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) var StaticTilemapLayerCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix)
{ {
src.cull(camera); src.cull(camera);
console.log("canvas renderer")
var renderTiles = src.culledTiles; var renderTiles = src.culledTiles;
var tileCount = renderTiles.length; var tileCount = renderTiles.length;

File diff suppressed because one or more lines are too long

48
dist/phaser.js vendored
View file

@ -14106,9 +14106,9 @@ module.exports = SetTileCollision;
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
var Class = __webpack_require__(0); var Class = __webpack_require__(0);
var Components = __webpack_require__(11); var Components = __webpack_require__(11);
var Rectangle = __webpack_require__(441); var Rectangle = __webpack_require__(441);
/** /**
* @classdesc * @classdesc
@ -14379,7 +14379,7 @@ var Tile = new Class({
* @since 3.0.0 * @since 3.0.0
*/ */
this.physics = {}; this.physics = {};
/** /**
* An empty object where physics-engine specific information (e.g. bodies) may be stored. * An empty object where physics-engine specific information (e.g. bodies) may be stored.
* *
* @name Phaser.Tilemaps.Tile#orientation * @name Phaser.Tilemaps.Tile#orientation
@ -14387,9 +14387,13 @@ var Tile = new Class({
* @since 3.2.PR_svipal * @since 3.2.PR_svipal
*/ */
// we default to orthogonal // we default to orthogonal
this.orientation = (orientation !== undefined) ? orientation : "orthogonal"; // we need to deep copy the string to prevent the orientation later going out of scope
if (orientation == undefined) {
// console.log("tile orientation : "+this.orientation) this.orientation = "orthogonal";
} else {
this.orientation = orientation // (' ' + orientation).slice(1)
}
console.log("tile orientation : "+this.orientation)
}, },
/** /**
@ -14822,25 +14826,23 @@ var Tile = new Class({
*/ */
updatePixelXY: function () updatePixelXY: function ()
{ {
// Tiled places tiles on a grid of baseWidth x baseHeight. The origin for a tile is the if (orientation === "orthogonal") {
// bottom left, while the Phaser renderer assumes the origin is the top left. The y // In orthogonal mode, Tiled places tiles on a grid of baseWidth x baseHeight. The origin for a tile is the
// coordinate needs to be adjusted by the difference. // bottom left, while the Phaser renderer assumes the origin is the top left. The y
console.log("width" + this.baseWidth) // coordinate needs to be adjusted by the difference.
console.log("height" + this.baseHeight)
if (this.orientation === "orthogonal") {
this.pixelX = this.x * this.baseWidth; this.pixelX = this.x * this.baseWidth;
this.pixelY = this.y * this.baseHeight; this.pixelY = this.y * this.baseHeight;
console.log("orthopix "+this.pixelX+","+this.pixelY) console.log("orthopix "+this.pixelX+","+this.pixelY)
} else if (this.orientation === "isometric") { } else if (orientation === "isometric" ) {
mapSize = 10 mapSize = 10
// once we get the 'top' of the losange we need to remove half of the tile width. // once we get the 'top' of the losange we need to remove half of the tile width.
this.pixelX = (this.baseWidth/2)*mapSize + (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; this.pixelY = (this.x + this.y) * this.baseHeight *0.5;
console.log("isopix "+this.pixelX+","+this.pixelY) console.log("isopix "+this.pixelX+","+this.pixelY)
console.log(this) console.log(self)
} else { } else {
console.log(this) console.log("self :" + self)
console.log("tile orientation : "+this.orientation) console.log("tile orientation 2: "+orientation)
} }
// this.pixelY = this.y * this.baseHeight - (this.height - this.baseHeight); // this.pixelY = this.y * this.baseHeight - (this.height - this.baseHeight);
@ -107735,6 +107737,8 @@ var ParseTileLayers = function (json, insertNull)
// index, x, y, width, height // index, x, y, width, height
if (gidInfo.gid > 0) 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, tile = new Tile(layerData, gidInfo.gid, newOffsetX, newOffsetY, json.tilewidth,
json.tileheight,json.orientation); json.tileheight,json.orientation);
@ -107747,6 +107751,8 @@ var ParseTileLayers = function (json, insertNull)
} }
else else
{ {
console.log("Tile ptl 2", newOffsetX, newOffsetY, json.tilewidth,
json.tileheight,json.orientation)
blankTile = insertNull blankTile = insertNull
? null ? null
: new Tile(layerData, -1, newOffsetX, newOffsetY, json.tilewidth, json.tileheight,json.orientation); : new Tile(layerData, -1, newOffsetX, newOffsetY, json.tilewidth, json.tileheight,json.orientation);
@ -107789,6 +107795,8 @@ var ParseTileLayers = function (json, insertNull)
// index, x, y, width, height // index, x, y, width, height
if (gidInfo.gid > 0) 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, tile = new Tile(layerData, gidInfo.gid, x, output.length, json.tilewidth,
json.tileheight, json.orientation); json.tileheight, json.orientation);
@ -107801,6 +107809,8 @@ var ParseTileLayers = function (json, insertNull)
} }
else else
{ {
console.log("Tile ptl 4", newOffsetX, newOffsetY, json.tilewidth,
json.tileheight,json.orientation)
blankTile = insertNull blankTile = insertNull
? null ? null
: new Tile(layerData, -1, x, output.length, json.tilewidth, json.tileheight, json.orientation); : new Tile(layerData, -1, x, output.length, json.tilewidth, json.tileheight, json.orientation);
@ -109432,7 +109442,7 @@ var Tilemap = new Class({
for (var tileX = 0; tileX < width; tileX++) for (var tileX = 0; tileX < width; tileX++)
{ {
console.log("Tile tm", 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)); row.push(new Tile(layerData, -1, tileX, tileY, tileWidth, tileHeight, this.orientation, this.tileWidth, this.tileHeight));
} }
@ -185096,7 +185106,6 @@ module.exports = {
*/ */
var StaticTilemapLayerWebGLRenderer = function (renderer, src, interpolationPercentage, camera) var StaticTilemapLayerWebGLRenderer = function (renderer, src, interpolationPercentage, camera)
{ {
console.log("webgl renderer")
var tilesets = src.tileset; var tilesets = src.tileset;
var pipeline = src.pipeline; var pipeline = src.pipeline;
@ -185168,7 +185177,6 @@ module.exports = StaticTilemapLayerWebGLRenderer;
var StaticTilemapLayerCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) var StaticTilemapLayerCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix)
{ {
src.cull(camera); src.cull(camera);
console.log("canvas renderer")
var renderTiles = src.culledTiles; var renderTiles = src.culledTiles;
var tileCount = renderTiles.length; var tileCount = renderTiles.length;

2
dist/phaser.min.js vendored

File diff suppressed because one or more lines are too long

View file

@ -277,17 +277,21 @@ var Tile = new Class({
* @since 3.0.0 * @since 3.0.0
*/ */
this.physics = {}; this.physics = {};
/** /**
* An empty object where physics-engine specific information (e.g. bodies) may be stored. * The tile's orientation, necessary to be able to determine pixelX and pixelY.
* *
* @name Phaser.Tilemaps.Tile#orientation * @name Phaser.Tilemaps.Tile#orientation
* @type {string} * @type {string}
* @since 3.2.PR_svipal * @since 3.2.PR_svipal
*/ */
// we default to orthogonal // we default to orthogonal
this.orientation = (orientation !== undefined) ? orientation : "orthogonal"; // we need to deep copy the string to prevent the orientation later going out of scope
if (orientation == undefined) {
// console.log("tile orientation : "+this.orientation) this.orientation = "orthogonal";
} else {
this.orientation = (' ' + orientation).slice(1)
}
console.log("tile orientation : "+this.orientation)
}, },
/** /**
@ -720,16 +724,15 @@ var Tile = new Class({
*/ */
updatePixelXY: function () updatePixelXY: function ()
{ {
// Tiled places tiles on a grid of baseWidth x baseHeight. The origin for a tile is the console.log("tile orientation 2: "+this.orientation)
// bottom left, while the Phaser renderer assumes the origin is the top left. The y
// coordinate needs to be adjusted by the difference.
console.log("width" + this.baseWidth)
console.log("height" + this.baseHeight)
if (this.orientation === "orthogonal") { if (this.orientation === "orthogonal") {
// In orthogonal mode, 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.
this.pixelX = this.x * this.baseWidth; this.pixelX = this.x * this.baseWidth;
this.pixelY = this.y * this.baseHeight; this.pixelY = this.y * this.baseHeight;
console.log("orthopix "+this.pixelX+","+this.pixelY) console.log("orthopix "+this.pixelX+","+this.pixelY)
} else if (this.orientation === "isometric") { } else if (this.orientation === "isometric" ) {
mapSize = 10 mapSize = 10
// once we get the 'top' of the losange we need to remove half of the tile width. // once we get the 'top' of the losange we need to remove half of the tile width.
this.pixelX = (this.baseWidth/2)*mapSize + (this.x - this.y) * this.baseWidth *0.5; this.pixelX = (this.baseWidth/2)*mapSize + (this.x - this.y) * this.baseWidth *0.5;
@ -737,8 +740,8 @@ var Tile = new Class({
console.log("isopix "+this.pixelX+","+this.pixelY) console.log("isopix "+this.pixelX+","+this.pixelY)
console.log(this) console.log(this)
} else { } else {
console.log(this) console.log("this :" + this)
console.log("tile orientation : "+this.orientation) console.log("tile orientation 3: "+this.orientation)
} }
// this.pixelY = this.y * this.baseHeight - (this.height - this.baseHeight); // this.pixelY = this.y * this.baseHeight - (this.height - this.baseHeight);

View file

@ -22,7 +22,6 @@
var StaticTilemapLayerCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) var StaticTilemapLayerCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix)
{ {
src.cull(camera); src.cull(camera);
console.log("canvas renderer")
var renderTiles = src.culledTiles; var renderTiles = src.culledTiles;
var tileCount = renderTiles.length; var tileCount = renderTiles.length;

View file

@ -23,7 +23,6 @@
*/ */
var StaticTilemapLayerWebGLRenderer = function (renderer, src, interpolationPercentage, camera) var StaticTilemapLayerWebGLRenderer = function (renderer, src, interpolationPercentage, camera)
{ {
console.log("webgl renderer")
var tilesets = src.tileset; var tilesets = src.tileset;
var pipeline = src.pipeline; var pipeline = src.pipeline;