@@ -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 ;
0 commit comments