You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Made a copy of Phaser.TilemapLayer which instead extends PIXI.Tilemap, then added functions to build a batch list of tile source and destination coordinates (instead of drawing them directly onto a Canvas). This maintains all the existing Phaser functionality in regards to tile map decoding and interpretation, and also provides maximum performance from the PIXI component by using a TRIANGLE_STRIP to render everything as a single batch job.
// Fix normStartX/normStartY such it is normalized [0..width/height). This allows a simple conditional and decrement to always keep in range [0..width/height) during the loop. The major offset bias is to take care of negative values.
702
+
varnormStartX=(left+((1<<20)*width))%width;
703
+
varnormStartY=(top+((1<<20)*height))%height;
704
+
705
+
// tx/ty - are pixel coordinates where tile is drawn
706
+
// x/y - is cell location, normalized [0..width/height) in loop
707
+
// xmax/ymax - remaining cells to render on column/row
708
+
vartx,ty,x,y,xmax,ymax;
709
+
710
+
//context.fillStyle = this.tileColor;
711
+
712
+
for(y=normStartY,ymax=bottom-top,ty=baseY;
713
+
ymax>=0;
714
+
y++,ymax--,ty+=th)
715
+
{
716
+
717
+
if(y>=height){y-=height;}
718
+
719
+
varrow=this.layer.data[y];
720
+
721
+
for(x=normStartX,xmax=right-left,tx=baseX;
722
+
xmax>=0;
723
+
x++,xmax--,tx+=tw)
724
+
{
725
+
726
+
if(x>=width){x-=width;}
727
+
728
+
vartile=row[x];
729
+
730
+
if(!tile||tile.index<0)
731
+
{
732
+
continue;
733
+
}
734
+
735
+
varindex=tile.index;
736
+
737
+
varset=tilesets[index];
738
+
739
+
if(set===undefined)
740
+
{
741
+
set=this.resolveTileset(index);
742
+
}
743
+
744
+
// Setting the globalAlpha is "surprisingly expensive" in Chrome (38)
745
+
if(tile.alpha!==lastAlpha&&!this.debug)
746
+
{
747
+
//context.globalAlpha = tile.alpha;
748
+
lastAlpha=tile.alpha;
749
+
}
750
+
751
+
if(set)
752
+
{
753
+
if(tile.rotation||tile.flipped)
754
+
{
755
+
//context.save();
756
+
//context.translate(tx + tile.centerX, ty + tile.centerY);
0 commit comments