@@ -86,20 +86,22 @@ var Tile = new Class({
8686 this . baseHeight = ( baseHeight !== undefined ) ? baseHeight : height ;
8787
8888 /**
89- * The world x coordinate of the top left of this tile in pixels. This does not factor in
90- * camera scroll, layer scale or layer position.
91- * @property {number } x
89+ * The x coordinate of the top left of this tile in pixels. This is relative to the top left
90+ * of the layer this tile is being rendered within. This property does NOT factor in camera
91+ * scroll, layer scale or layer position.
92+ * @property {number } pixelX
9293 */
93- this . worldX = 0 ;
94+ this . pixelX = 0 ;
9495
9596 /**
96- * The world y coordinate of the top left of this tile in pixels. This does not factor in
97- * camera scroll, layer scale or layer position.
98- * @property {number } y
97+ * The y coordinate of the top left of this tile in pixels. This is relative to the top left
98+ * of the layer this tile is being rendered within. This property does NOT factor in camera
99+ * scroll, layer scale or layer position.
100+ * @property {number } pixelY
99101 */
100- this . worldY = 0 ;
102+ this . pixelY = 0 ;
101103
102- this . updateWorldXY ( ) ;
104+ this . updatePixelXY ( ) ;
103105
104106 /**
105107 * Tile specific properties. These usually come from Tiled.
@@ -192,7 +194,7 @@ var Tile = new Class({
192194 */
193195 containsPoint : function ( x , y )
194196 {
195- return ! ( x < this . worldX || y < this . worldY || x > this . right || y > this . bottom ) ;
197+ return ! ( x < this . pixelX || y < this . pixelY || x > this . right || y > this . bottom ) ;
196198 } ,
197199
198200 /**
@@ -244,7 +246,7 @@ var Tile = new Class({
244246 intersects : function ( x , y , right , bottom )
245247 {
246248 return ! (
247- right <= this . worldX || bottom <= this . worldY ||
249+ right <= this . pixelX || bottom <= this . pixelY ||
248250 x >= this . right || y >= this . bottom
249251 ) ;
250252 } ,
@@ -354,7 +356,7 @@ var Tile = new Class({
354356 } ,
355357
356358 /**
357- * Sets the size of the tile and updates its worldX and worldY .
359+ * Sets the size of the tile and updates its pixelX and pixelY .
358360 *
359361 * @param {integer } tileWidth - The width of the tile in pixels.
360362 * @param {integer } tileHeight - The height of the tile in pixels.
@@ -369,7 +371,7 @@ var Tile = new Class({
369371 if ( baseWidth !== undefined ) { this . baseWidth = baseWidth ; }
370372 if ( baseHeight !== undefined ) { this . baseHeight = baseHeight ; }
371373
372- this . updateWorldXY ( ) ;
374+ this . updatePixelXY ( ) ;
373375
374376 return this ;
375377 } ,
@@ -379,13 +381,13 @@ var Tile = new Class({
379381 *
380382 * @returns {this }
381383 */
382- updateWorldXY : function ( )
384+ updatePixelXY : function ( )
383385 {
384386 // Tiled places tiles on a grid of baseWidth x baseHeight. The origin for a tile is the
385387 // bottom left, while the Phaser renderer assumes the origin is the top left. The y
386388 // coordinate needs to be adjusted by the difference.
387- this . worldX = this . x * this . baseWidth ;
388- this . worldY = this . y * this . baseHeight - ( this . height - this . baseHeight ) ;
389+ this . pixelX = this . x * this . baseWidth ;
390+ this . pixelY = this . y * this . baseHeight - ( this . height - this . baseHeight ) ;
389391
390392 return this ;
391393 } ,
@@ -435,7 +437,7 @@ var Tile = new Class({
435437 left : {
436438 get : function ( )
437439 {
438- return this . worldX ;
440+ return this . pixelX ;
439441 }
440442 } ,
441443
@@ -448,7 +450,7 @@ var Tile = new Class({
448450 right : {
449451 get : function ( )
450452 {
451- return this . worldX + this . width ;
453+ return this . pixelX + this . width ;
452454 }
453455 } ,
454456
@@ -461,7 +463,7 @@ var Tile = new Class({
461463 top : {
462464 get : function ( )
463465 {
464- return this . worldY ;
466+ return this . pixelY ;
465467 }
466468 } ,
467469
@@ -474,7 +476,7 @@ var Tile = new Class({
474476 bottom : {
475477 get : function ( )
476478 {
477- return this . worldY + this . height ;
479+ return this . pixelY + this . height ;
478480 }
479481 } ,
480482
@@ -487,7 +489,7 @@ var Tile = new Class({
487489 centerX : {
488490 get : function ( )
489491 {
490- return this . worldX + this . width / 2 ;
492+ return this . pixelX + this . width / 2 ;
491493 }
492494 } ,
493495
@@ -500,7 +502,7 @@ var Tile = new Class({
500502 centerY : {
501503 get : function ( )
502504 {
503- return this . worldY + this . height / 2 ;
505+ return this . pixelY + this . height / 2 ;
504506 }
505507 }
506508
0 commit comments