@@ -464,12 +464,14 @@ Phaser.TilemapLayerGL.prototype.renderRegion = function (scrollX, scrollY, left,
464464 // x/y - is cell location, normalized [0..width/height) in loop
465465 // xmax/ymax - remaining cells to render on column/row
466466 var tx , ty , x , y , xmax , ymax ;
467+ var tileset = this . _mc . tileset ;
467468
468469 for ( y = normStartY , ymax = bottom - top , ty = baseY ; ymax >= 0 ; y ++ , ymax -- , ty += th )
469470 {
470471 if ( y >= height )
471472 {
472- y -= height ;
473+ // wrap around if coordinates go out of range 0..height
474+ y %= height ;
473475 }
474476
475477 var row = this . layer . data [ y ] ;
@@ -478,7 +480,8 @@ Phaser.TilemapLayerGL.prototype.renderRegion = function (scrollX, scrollY, left,
478480 {
479481 if ( x >= width )
480482 {
481- x -= width ;
483+ // wrap around if coordinates go out of range 0..width
484+ x %= width ;
482485 }
483486
484487 var tile = row [ x ] ;
@@ -487,23 +490,23 @@ Phaser.TilemapLayerGL.prototype.renderRegion = function (scrollX, scrollY, left,
487490 if ( ! tile || tile . index < this . _mc . tileset . firstgid || tile . index > this . _mc . lastgid )
488491 {
489492 // skipping some tiles, add a degenerate marker into the batch list
490- this . _mc . tileset . addDegenerate ( this . glBatch ) ;
493+ tileset . addDegenerate ( this . glBatch ) ;
491494 continue ;
492495 }
493496
494497 var index = tile . index ;
495498
496- this . _mc . tileset . drawGl ( this . glBatch , tx + offx , ty + offy , index , tile . alpha , tile . flippedVal ) ;
499+ tileset . drawGl ( this . glBatch , tx + offx , ty + offy , index , tile . alpha , tile . flippedVal ) ;
497500 }
498501
499502 // at end of each row, add a degenerate marker into the batch drawing list
500- this . _mc . tileset . addDegenerate ( this . glBatch ) ;
503+ tileset . addDegenerate ( this . glBatch ) ;
501504 }
502505
503506} ;
504507
505508/**
506- * Clear and render the entire canvas .
509+ * Render the entire visible region of the map .
507510*
508511* @method Phaser.TilemapLayerGL#renderFull
509512* @private
0 commit comments