Skip to content

Commit a82b27c

Browse files
committed
added deep copy, doesn't change anything , this.orientation in the tile still bugging
1 parent 050325b commit a82b27c

7 files changed

Lines changed: 74 additions & 57 deletions

File tree

dist/phaser-arcade-physics.js

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12182,9 +12182,9 @@ module.exports = SetTileCollision;
1218212182
* @license {@link https://opensource.org/licenses/MIT|MIT License}
1218312183
*/
1218412184

12185-
var Class = __webpack_require__(0);
12186-
var Components = __webpack_require__(11);
12187-
var Rectangle = __webpack_require__(441);
12185+
var Class = __webpack_require__(0);
12186+
var Components = __webpack_require__(11);
12187+
var Rectangle = __webpack_require__(441);
1218812188

1218912189
/**
1219012190
* @classdesc
@@ -12455,17 +12455,21 @@ var Tile = new Class({
1245512455
* @since 3.0.0
1245612456
*/
1245712457
this.physics = {};
12458-
/**
12458+
/**
1245912459
* An empty object where physics-engine specific information (e.g. bodies) may be stored.
1246012460
*
1246112461
* @name Phaser.Tilemaps.Tile#orientation
1246212462
* @type {string}
1246312463
* @since 3.2.PR_svipal
1246412464
*/
1246512465
// we default to orthogonal
12466-
this.orientation = (orientation !== undefined) ? orientation : "orthogonal";
12467-
12468-
// console.log("tile orientation : "+this.orientation)
12466+
// we need to deep copy the string to prevent the orientation later going out of scope
12467+
if (orientation == undefined) {
12468+
this.orientation = "orthogonal";
12469+
} else {
12470+
this.orientation = orientation // (' ' + orientation).slice(1)
12471+
}
12472+
console.log("tile orientation : "+this.orientation)
1246912473
},
1247012474

1247112475
/**
@@ -12898,25 +12902,23 @@ var Tile = new Class({
1289812902
*/
1289912903
updatePixelXY: function ()
1290012904
{
12901-
// Tiled places tiles on a grid of baseWidth x baseHeight. The origin for a tile is the
12902-
// bottom left, while the Phaser renderer assumes the origin is the top left. The y
12903-
// coordinate needs to be adjusted by the difference.
12904-
console.log("width" + this.baseWidth)
12905-
console.log("height" + this.baseHeight)
12906-
if (this.orientation === "orthogonal") {
12905+
if (orientation === "orthogonal") {
12906+
// In orthogonal mode, Tiled places tiles on a grid of baseWidth x baseHeight. The origin for a tile is the
12907+
// bottom left, while the Phaser renderer assumes the origin is the top left. The y
12908+
// coordinate needs to be adjusted by the difference.
1290712909
this.pixelX = this.x * this.baseWidth;
1290812910
this.pixelY = this.y * this.baseHeight;
1290912911
console.log("orthopix "+this.pixelX+","+this.pixelY)
12910-
} else if (this.orientation === "isometric") {
12912+
} else if (orientation === "isometric" ) {
1291112913
mapSize = 10
1291212914
// once we get the 'top' of the losange we need to remove half of the tile width.
1291312915
this.pixelX = (this.baseWidth/2)*mapSize + (this.x - this.y) * this.baseWidth *0.5;
1291412916
this.pixelY = (this.x + this.y) * this.baseHeight *0.5;
1291512917
console.log("isopix "+this.pixelX+","+this.pixelY)
12916-
console.log(this)
12918+
console.log(self)
1291712919
} else {
12918-
console.log(this)
12919-
console.log("tile orientation : "+this.orientation)
12920+
console.log("self :" + self)
12921+
console.log("tile orientation 2: "+orientation)
1292012922
}
1292112923

1292212924
// this.pixelY = this.y * this.baseHeight - (this.height - this.baseHeight);
@@ -102924,6 +102926,8 @@ var ParseTileLayers = function (json, insertNull)
102924102926
// index, x, y, width, height
102925102927
if (gidInfo.gid > 0)
102926102928
{
102929+
console.log("Tile ptl 1", newOffsetX, newOffsetY, json.tilewidth,
102930+
json.tileheight,json.orientation)
102927102931
tile = new Tile(layerData, gidInfo.gid, newOffsetX, newOffsetY, json.tilewidth,
102928102932
json.tileheight,json.orientation);
102929102933

@@ -102936,6 +102940,8 @@ var ParseTileLayers = function (json, insertNull)
102936102940
}
102937102941
else
102938102942
{
102943+
console.log("Tile ptl 2", newOffsetX, newOffsetY, json.tilewidth,
102944+
json.tileheight,json.orientation)
102939102945
blankTile = insertNull
102940102946
? null
102941102947
: new Tile(layerData, -1, newOffsetX, newOffsetY, json.tilewidth, json.tileheight,json.orientation);
@@ -102978,6 +102984,8 @@ var ParseTileLayers = function (json, insertNull)
102978102984
// index, x, y, width, height
102979102985
if (gidInfo.gid > 0)
102980102986
{
102987+
console.log("Tile ptl 3", newOffsetX, newOffsetY, json.tilewidth,
102988+
json.tileheight,json.orientation)
102981102989
tile = new Tile(layerData, gidInfo.gid, x, output.length, json.tilewidth,
102982102990
json.tileheight, json.orientation);
102983102991

@@ -102990,6 +102998,8 @@ var ParseTileLayers = function (json, insertNull)
102990102998
}
102991102999
else
102992103000
{
103001+
console.log("Tile ptl 4", newOffsetX, newOffsetY, json.tilewidth,
103002+
json.tileheight,json.orientation)
102993103003
blankTile = insertNull
102994103004
? null
102995103005
: new Tile(layerData, -1, x, output.length, json.tilewidth, json.tileheight, json.orientation);
@@ -104621,7 +104631,7 @@ var Tilemap = new Class({
104621104631

104622104632
for (var tileX = 0; tileX < width; tileX++)
104623104633
{
104624-
console.log("Tile tm", tileX, tileY, tileWidth, tileHeight, this.tileWidth, this.tileHeight, this.orientation)
104634+
console.log("Tile tm", tileX, tileY, tileWidth, tileHeight, this.orientation, this.tileWidth, this.tileHeight)
104625104635
row.push(new Tile(layerData, -1, tileX, tileY, tileWidth, tileHeight, this.orientation, this.tileWidth, this.tileHeight));
104626104636
}
104627104637

@@ -177177,7 +177187,6 @@ module.exports = {
177177177187
*/
177178177188
var StaticTilemapLayerWebGLRenderer = function (renderer, src, interpolationPercentage, camera)
177179177189
{
177180-
console.log("webgl renderer")
177181177190
var tilesets = src.tileset;
177182177191

177183177192
var pipeline = src.pipeline;
@@ -177249,7 +177258,6 @@ module.exports = StaticTilemapLayerWebGLRenderer;
177249177258
var StaticTilemapLayerCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix)
177250177259
{
177251177260
src.cull(camera);
177252-
console.log("canvas renderer")
177253177261
var renderTiles = src.culledTiles;
177254177262
var tileCount = renderTiles.length;
177255177263

dist/phaser-arcade-physics.min.js

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

dist/phaser.js

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14106,9 +14106,9 @@ module.exports = SetTileCollision;
1410614106
* @license {@link https://opensource.org/licenses/MIT|MIT License}
1410714107
*/
1410814108

14109-
var Class = __webpack_require__(0);
14110-
var Components = __webpack_require__(11);
14111-
var Rectangle = __webpack_require__(441);
14109+
var Class = __webpack_require__(0);
14110+
var Components = __webpack_require__(11);
14111+
var Rectangle = __webpack_require__(441);
1411214112

1411314113
/**
1411414114
* @classdesc
@@ -14379,17 +14379,21 @@ var Tile = new Class({
1437914379
* @since 3.0.0
1438014380
*/
1438114381
this.physics = {};
14382-
/**
14382+
/**
1438314383
* An empty object where physics-engine specific information (e.g. bodies) may be stored.
1438414384
*
1438514385
* @name Phaser.Tilemaps.Tile#orientation
1438614386
* @type {string}
1438714387
* @since 3.2.PR_svipal
1438814388
*/
1438914389
// we default to orthogonal
14390-
this.orientation = (orientation !== undefined) ? orientation : "orthogonal";
14391-
14392-
// console.log("tile orientation : "+this.orientation)
14390+
// we need to deep copy the string to prevent the orientation later going out of scope
14391+
if (orientation == undefined) {
14392+
this.orientation = "orthogonal";
14393+
} else {
14394+
this.orientation = orientation // (' ' + orientation).slice(1)
14395+
}
14396+
console.log("tile orientation : "+this.orientation)
1439314397
},
1439414398

1439514399
/**
@@ -14822,25 +14826,23 @@ var Tile = new Class({
1482214826
*/
1482314827
updatePixelXY: function ()
1482414828
{
14825-
// Tiled places tiles on a grid of baseWidth x baseHeight. The origin for a tile is the
14826-
// bottom left, while the Phaser renderer assumes the origin is the top left. The y
14827-
// coordinate needs to be adjusted by the difference.
14828-
console.log("width" + this.baseWidth)
14829-
console.log("height" + this.baseHeight)
14830-
if (this.orientation === "orthogonal") {
14829+
if (orientation === "orthogonal") {
14830+
// In orthogonal mode, Tiled places tiles on a grid of baseWidth x baseHeight. The origin for a tile is the
14831+
// bottom left, while the Phaser renderer assumes the origin is the top left. The y
14832+
// coordinate needs to be adjusted by the difference.
1483114833
this.pixelX = this.x * this.baseWidth;
1483214834
this.pixelY = this.y * this.baseHeight;
1483314835
console.log("orthopix "+this.pixelX+","+this.pixelY)
14834-
} else if (this.orientation === "isometric") {
14836+
} else if (orientation === "isometric" ) {
1483514837
mapSize = 10
1483614838
// once we get the 'top' of the losange we need to remove half of the tile width.
1483714839
this.pixelX = (this.baseWidth/2)*mapSize + (this.x - this.y) * this.baseWidth *0.5;
1483814840
this.pixelY = (this.x + this.y) * this.baseHeight *0.5;
1483914841
console.log("isopix "+this.pixelX+","+this.pixelY)
14840-
console.log(this)
14842+
console.log(self)
1484114843
} else {
14842-
console.log(this)
14843-
console.log("tile orientation : "+this.orientation)
14844+
console.log("self :" + self)
14845+
console.log("tile orientation 2: "+orientation)
1484414846
}
1484514847

1484614848
// this.pixelY = this.y * this.baseHeight - (this.height - this.baseHeight);
@@ -107735,6 +107737,8 @@ var ParseTileLayers = function (json, insertNull)
107735107737
// index, x, y, width, height
107736107738
if (gidInfo.gid > 0)
107737107739
{
107740+
console.log("Tile ptl 1", newOffsetX, newOffsetY, json.tilewidth,
107741+
json.tileheight,json.orientation)
107738107742
tile = new Tile(layerData, gidInfo.gid, newOffsetX, newOffsetY, json.tilewidth,
107739107743
json.tileheight,json.orientation);
107740107744

@@ -107747,6 +107751,8 @@ var ParseTileLayers = function (json, insertNull)
107747107751
}
107748107752
else
107749107753
{
107754+
console.log("Tile ptl 2", newOffsetX, newOffsetY, json.tilewidth,
107755+
json.tileheight,json.orientation)
107750107756
blankTile = insertNull
107751107757
? null
107752107758
: new Tile(layerData, -1, newOffsetX, newOffsetY, json.tilewidth, json.tileheight,json.orientation);
@@ -107789,6 +107795,8 @@ var ParseTileLayers = function (json, insertNull)
107789107795
// index, x, y, width, height
107790107796
if (gidInfo.gid > 0)
107791107797
{
107798+
console.log("Tile ptl 3", newOffsetX, newOffsetY, json.tilewidth,
107799+
json.tileheight,json.orientation)
107792107800
tile = new Tile(layerData, gidInfo.gid, x, output.length, json.tilewidth,
107793107801
json.tileheight, json.orientation);
107794107802

@@ -107801,6 +107809,8 @@ var ParseTileLayers = function (json, insertNull)
107801107809
}
107802107810
else
107803107811
{
107812+
console.log("Tile ptl 4", newOffsetX, newOffsetY, json.tilewidth,
107813+
json.tileheight,json.orientation)
107804107814
blankTile = insertNull
107805107815
? null
107806107816
: new Tile(layerData, -1, x, output.length, json.tilewidth, json.tileheight, json.orientation);
@@ -109432,7 +109442,7 @@ var Tilemap = new Class({
109432109442

109433109443
for (var tileX = 0; tileX < width; tileX++)
109434109444
{
109435-
console.log("Tile tm", tileX, tileY, tileWidth, tileHeight, this.tileWidth, this.tileHeight, this.orientation)
109445+
console.log("Tile tm", tileX, tileY, tileWidth, tileHeight, this.orientation, this.tileWidth, this.tileHeight)
109436109446
row.push(new Tile(layerData, -1, tileX, tileY, tileWidth, tileHeight, this.orientation, this.tileWidth, this.tileHeight));
109437109447
}
109438109448

@@ -185096,7 +185106,6 @@ module.exports = {
185096185106
*/
185097185107
var StaticTilemapLayerWebGLRenderer = function (renderer, src, interpolationPercentage, camera)
185098185108
{
185099-
console.log("webgl renderer")
185100185109
var tilesets = src.tileset;
185101185110

185102185111
var pipeline = src.pipeline;
@@ -185168,7 +185177,6 @@ module.exports = StaticTilemapLayerWebGLRenderer;
185168185177
var StaticTilemapLayerCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix)
185169185178
{
185170185179
src.cull(camera);
185171-
console.log("canvas renderer")
185172185180
var renderTiles = src.culledTiles;
185173185181
var tileCount = renderTiles.length;
185174185182

dist/phaser.min.js

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

src/tilemaps/Tile.js

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -277,17 +277,21 @@ var Tile = new Class({
277277
* @since 3.0.0
278278
*/
279279
this.physics = {};
280-
/**
281-
* An empty object where physics-engine specific information (e.g. bodies) may be stored.
280+
/**
281+
* The tile's orientation, necessary to be able to determine pixelX and pixelY.
282282
*
283283
* @name Phaser.Tilemaps.Tile#orientation
284284
* @type {string}
285285
* @since 3.2.PR_svipal
286286
*/
287287
// we default to orthogonal
288-
this.orientation = (orientation !== undefined) ? orientation : "orthogonal";
289-
290-
// console.log("tile orientation : "+this.orientation)
288+
// we need to deep copy the string to prevent the orientation later going out of scope
289+
if (orientation == undefined) {
290+
this.orientation = "orthogonal";
291+
} else {
292+
this.orientation = (' ' + orientation).slice(1)
293+
}
294+
console.log("tile orientation : "+this.orientation)
291295
},
292296

293297
/**
@@ -720,25 +724,24 @@ var Tile = new Class({
720724
*/
721725
updatePixelXY: function ()
722726
{
723-
// Tiled places tiles on a grid of baseWidth x baseHeight. The origin for a tile is the
724-
// bottom left, while the Phaser renderer assumes the origin is the top left. The y
725-
// coordinate needs to be adjusted by the difference.
726-
console.log("width" + this.baseWidth)
727-
console.log("height" + this.baseHeight)
727+
console.log("tile orientation 2: "+this.orientation)
728728
if (this.orientation === "orthogonal") {
729+
// In orthogonal mode, Tiled places tiles on a grid of baseWidth x baseHeight. The origin for a tile is the
730+
// bottom left, while the Phaser renderer assumes the origin is the top left. The y
731+
// coordinate needs to be adjusted by the difference.
729732
this.pixelX = this.x * this.baseWidth;
730733
this.pixelY = this.y * this.baseHeight;
731734
console.log("orthopix "+this.pixelX+","+this.pixelY)
732-
} else if (this.orientation === "isometric") {
735+
} else if (this.orientation === "isometric" ) {
733736
mapSize = 10
734737
// once we get the 'top' of the losange we need to remove half of the tile width.
735738
this.pixelX = (this.baseWidth/2)*mapSize + (this.x - this.y) * this.baseWidth *0.5;
736739
this.pixelY = (this.x + this.y) * this.baseHeight *0.5;
737740
console.log("isopix "+this.pixelX+","+this.pixelY)
738741
console.log(this)
739742
} else {
740-
console.log(this)
741-
console.log("tile orientation : "+this.orientation)
743+
console.log("this :" + this)
744+
console.log("tile orientation 3: "+this.orientation)
742745
}
743746

744747
// this.pixelY = this.y * this.baseHeight - (this.height - this.baseHeight);

src/tilemaps/staticlayer/StaticTilemapLayerCanvasRenderer.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
var StaticTilemapLayerCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix)
2323
{
2424
src.cull(camera);
25-
console.log("canvas renderer")
2625
var renderTiles = src.culledTiles;
2726
var tileCount = renderTiles.length;
2827

src/tilemaps/staticlayer/StaticTilemapLayerWebGLRenderer.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
*/
2424
var StaticTilemapLayerWebGLRenderer = function (renderer, src, interpolationPercentage, camera)
2525
{
26-
console.log("webgl renderer")
2726
var tilesets = src.tileset;
2827

2928
var pipeline = src.pipeline;

0 commit comments

Comments
 (0)