44 * @license {@link https://opensource.org/licenses/MIT|MIT License }
55 */
66
7- var CONST = require ( '.. /const.js' ) ;
7+ var CONST = require ( './const.js' ) ;
88var Class = require ( '../utils/Class' ) ;
99var Components = require ( '../gameobjects/components' ) ;
1010var Rectangle = require ( '../geom/rectangle' ) ;
@@ -303,7 +303,7 @@ var Tile = new Class({
303303 *
304304 * @param {Phaser.Tilemaps.Tile } tile - The tile to copy from.
305305 *
306- * @return {Phaser.Tilemaps.Tile } This Tile object.
306+ * @return {this } This Tile object instance .
307307 */
308308 copy : function ( tile )
309309 {
@@ -552,7 +552,7 @@ var Tile = new Class({
552552 *
553553 * @param {boolean } [recalculateFaces=true] - Whether or not to recalculate interesting faces for this tile and its neighbors.
554554 *
555- * @return {Phaser.Tilemaps.Tile } This Tile object.
555+ * @return {this } This Tile object instance .
556556 */
557557 resetCollision : function ( recalculateFaces )
558558 {
@@ -587,7 +587,7 @@ var Tile = new Class({
587587 * @method Phaser.Tilemaps.Tile#resetFaces
588588 * @since 3.0.0
589589 *
590- * @return {Phaser.Tilemaps.Tile } This Tile object.
590+ * @return {this } This Tile object instance .
591591 */
592592 resetFaces : function ( )
593593 {
@@ -612,7 +612,7 @@ var Tile = new Class({
612612 * @param {boolean } [recalculateFaces=true] - Whether or not to recalculate interesting faces
613613 * for this tile and its neighbors.
614614 *
615- * @return {Phaser.Tilemaps.Tile } This Tile object.
615+ * @return {this } This Tile object instance .
616616 */
617617 setCollision : function ( left , right , up , down , recalculateFaces )
618618 {
@@ -654,7 +654,7 @@ var Tile = new Class({
654654 * @param {function } callback - Callback function.
655655 * @param {object } context - Callback will be called within this context.
656656 *
657- * @return {Phaser.Tilemaps.Tile } This Tile object.
657+ * @return {this } This Tile object instance .
658658 */
659659 setCollisionCallback : function ( callback , context )
660660 {
@@ -683,7 +683,7 @@ var Tile = new Class({
683683 * @param {integer } baseWidth - The base width a tile in the map (in pixels).
684684 * @param {integer } baseHeight - The base height of the tile in pixels (in pixels).
685685 *
686- * @return {Phaser.Tilemaps.Tile } This Tile object.
686+ * @return {this } This Tile object instance .
687687 */
688688 setSize : function ( tileWidth , tileHeight , baseWidth , baseHeight )
689689 {
@@ -698,43 +698,48 @@ var Tile = new Class({
698698 } ,
699699
700700 /**
701- * Used internally. Updates the tile's world XY position based on the current tile size.
701+ * Used internally. Updates the tiles world XY position based on the current tile size.
702702 *
703703 * @method Phaser.Tilemaps.Tile#updatePixelXY
704704 * @since 3.0.0
705705 *
706- * @return {Phaser.Tilemaps.Tile } This Tile object.
706+ * @return {this } This Tile object instance .
707707 */
708708 updatePixelXY : function ( )
709709 {
710- if ( this . layer . orientation === CONST . ISOMETRIC )
710+ var orientation = this . layer . orientation ;
711+
712+ if ( orientation === CONST . ORTHOGONAL )
711713 {
712- // reminder : for the tilemap to be centered we have to move the image to the right with the camera !
713- // this is crucial for wordtotile, tiletoworld to work.
714+ // In orthogonal mode, Tiled places tiles on a grid of baseWidth x baseHeight. The origin for a tile is the
715+ // bottom left, while the Phaser renderer assumes the origin is the top left. The y
716+ // coordinate needs to be adjusted by the difference.
717+
718+ this . pixelX = this . x * this . baseWidth ;
719+ this . pixelY = this . y * this . baseHeight ;
720+ }
721+ else if ( orientation === CONST . ISOMETRIC )
722+ {
723+ // Reminder: For the tilemap to be centered we have to move the image to the right with the camera!
724+ // This is crucial for wordtotile, tiletoworld to work.
725+
714726 this . pixelX = ( this . x - this . y ) * this . baseWidth * 0.5 ;
715727 this . pixelY = ( this . x + this . y ) * this . baseHeight * 0.5 ;
716728 }
717- else if ( this . layer . orientation === CONST . STAGGERED )
729+ else if ( orientation === CONST . STAGGERED )
718730 {
719731 this . pixelX = this . x * this . baseWidth + this . y % 2 * ( this . baseWidth / 2 ) ;
720732 this . pixelY = this . y * ( this . baseHeight / 2 ) ;
721733 }
722- else if ( this . layer . orientation === CONST . HEXAGONAL )
734+ else if ( orientation === CONST . HEXAGONAL )
723735 {
724736 var sidel = this . layer . hexSideLength ;
725737 var rowHeight = ( ( this . baseHeight - sidel ) / 2 + sidel ) ;
738+
726739 this . pixelX = this . x * this . baseWidth + this . y % 2 * ( this . baseWidth / 2 ) ;
727740 this . pixelY = this . y * rowHeight ;
728741 }
729- else if ( this . layer . orientation === CONST . ORTHOGONAL )
730- {
731- // In orthogonal mode, Tiled places tiles on a grid of baseWidth x baseHeight. The origin for a tile is the
732- // bottom left, while the Phaser renderer assumes the origin is the top left. The y
733- // coordinate needs to be adjusted by the difference.
734- this . pixelX = this . x * this . baseWidth ;
735- this . pixelY = this . y * this . baseHeight ;
736-
737- }
742+
738743 return this ;
739744 } ,
740745
0 commit comments