@@ -368,7 +368,7 @@ Phaser.TilemapLayer.prototype.updateMapData = function (tilemap, layer) {
368368}
369369
370370/**
371- * Take an x coordinate that doesn't account for scrollFactorY and 'fix' it
371+ * Take an x coordinate that doesn't account for scrollFactorX and 'fix' it
372372* into a scrolled local space. Used primarily internally
373373* @method Phaser.TilemapLayer#_fixX
374374* @memberof Phaser.TilemapLayer
@@ -378,19 +378,22 @@ Phaser.TilemapLayer.prototype.updateMapData = function (tilemap, layer) {
378378*/
379379Phaser . TilemapLayer . prototype . _fixX = function ( x ) {
380380
381+ if ( x < 0 )
382+ {
383+ x = 0 ;
384+ }
385+
381386 if ( this . scrollFactorX === 1 )
382387 {
383388 return x ;
384389 }
385390
386- var leftEdge = x - ( this . _x / this . scrollFactorX ) ;
387-
388- return this . _x + leftEdge ;
391+ return this . _x + ( x - ( this . _x / this . scrollFactorX ) ) ;
389392
390393}
391394
392395/**
393- * Take an x coordinate that _does_ account for scrollFactorY and 'unfix' it
396+ * Take an x coordinate that _does_ account for scrollFactorX and 'unfix' it
394397* back to camera space. Used primarily internally
395398* @method Phaser.TilemapLayer#_unfixX
396399* @memberof Phaser.TilemapLayer
@@ -405,9 +408,7 @@ Phaser.TilemapLayer.prototype._unfixX = function(x) {
405408 return x ;
406409 }
407410
408- var leftEdge = x - this . _x ;
409-
410- return ( this . _x / this . scrollFactorX ) + leftEdge ;
411+ return ( this . _x / this . scrollFactorX ) + ( x - this . _x ) ;
411412
412413}
413414
@@ -422,14 +423,17 @@ Phaser.TilemapLayer.prototype._unfixX = function(x) {
422423*/
423424Phaser . TilemapLayer . prototype . _fixY = function ( y ) {
424425
426+ if ( y < 0 )
427+ {
428+ y = 0 ;
429+ }
430+
425431 if ( this . scrollFactorY === 1 )
426432 {
427433 return y ;
428434 }
429435
430- var topEdge = y - ( this . _y / this . scrollFactorY ) ;
431-
432- return this . _y + topEdge ;
436+ return this . _y + ( y - ( this . _y / this . scrollFactorY ) ) ;
433437
434438}
435439
@@ -449,9 +453,7 @@ Phaser.TilemapLayer.prototype._unfixY = function(y) {
449453 return y ;
450454 }
451455
452- var topEdge = y - this . _y ;
453-
454- return ( this . _y / this . scrollFactorY ) + topEdge ;
456+ return ( this . _y / this . scrollFactorY ) + ( y - this . _y ) ;
455457
456458}
457459
@@ -524,18 +526,6 @@ Phaser.TilemapLayer.prototype.getTiles = function (x, y, width, height, collides
524526 if ( typeof collides === 'undefined' ) { collides = false ; }
525527 if ( typeof debug === 'undefined' ) { debug = false ; }
526528
527- // Cap the values
528-
529- if ( x < 0 )
530- {
531- x = 0 ;
532- }
533-
534- if ( y < 0 )
535- {
536- y = 0 ;
537- }
538-
539529 // adjust the x,y coordinates for scrollFactor
540530 x = this . _fixX ( x ) ;
541531 y = this . _fixY ( y ) ;
@@ -702,7 +692,7 @@ Phaser.TilemapLayer.prototype.render = function () {
702692
703693 if ( ! this . dirty || ! this . tileset || ! this . tilemap || ! this . visible )
704694 {
705- // return;
695+ return ;
706696 }
707697
708698 this . _prevX = this . _dx ;
@@ -720,8 +710,8 @@ Phaser.TilemapLayer.prototype.render = function () {
720710 this . _ty = this . _dy ;
721711
722712 this . context . clearRect ( 0 , 0 , this . canvas . width , this . canvas . height ) ;
723- this . context . fillStyle = '#000000' ;
724- this . context . fillRect ( 0 , 0 , this . canvas . width , this . canvas . height ) ;
713+ // this.context.fillStyle = '#000000';
714+ // this.context.fillRect(0, 0, this.canvas.width, this.canvas.height);
725715
726716 this . context . strokeStyle = '#00ff00' ;
727717
@@ -733,6 +723,23 @@ Phaser.TilemapLayer.prototype.render = function () {
733723 {
734724 var tile = this . _column [ x ] ;
735725
726+ // var tile = this.tileset.tiles[this._column[x] - 1];
727+
728+ if ( tile )
729+ {
730+ // this.context.drawImage(
731+ // this.tileset.image,
732+ // tile.x,
733+ // tile.y,
734+ // this.tileWidth,
735+ // this.tileHeight,
736+ // Math.floor(this._tx),
737+ // Math.floor(this._ty),
738+ // this.tileWidth,
739+ // this.tileHeight
740+ // );
741+ }
742+
736743 if ( tile && ( tile . faceTop || tile . faceBottom || tile . faceLeft || tile . faceRight ) )
737744 {
738745 this . _tx = Math . floor ( this . _tx ) ;
@@ -769,26 +776,6 @@ Phaser.TilemapLayer.prototype.render = function () {
769776 // this.context.strokeRect(this._tx, this._ty, this.tileWidth, this.tileHeight);
770777 }
771778
772- // only -1 on TILED maps, not CSV
773- /*
774- var tile = this.tileset.tiles[this._column[x]-1];
775-
776- if (tile)
777- {
778- this.context.drawImage(
779- this.tileset.image,
780- tile.x,
781- tile.y,
782- this.tileWidth,
783- this.tileHeight,
784- Math.floor(this._tx),
785- Math.floor(this._ty),
786- this.tileWidth,
787- this.tileHeight
788- );
789- }
790- */
791-
792779 this . _tx += this . tileWidth ;
793780
794781 }
0 commit comments