Skip to content

Commit 9daf6d0

Browse files
committed
Clean-up and comments.
1 parent 5f6ea15 commit 9daf6d0

1 file changed

Lines changed: 14 additions & 31 deletions

File tree

src/tilemap/TilemapLayerGL.js

Lines changed: 14 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,13 @@
55
*/
66

77
/**
8-
* A TilemapLayerGL is a PIXI.Tilemap that renders a specific TileLayer of a Tilemap.
8+
* A TilemapLayerGL is a PIXI.Tilemap that renders a specific TileLayer of a Tilemap using the PIXI WebGl renderer.
9+
* NOTE: this is a close duplicate of Phaser.TilemapLayer modified to support WebGl rendering, it may be possible to merge the two classes
10+
* although that will probably incur performance penalties due to some fundamental differences in the set-up before rendering.
11+
* Ideally it would be great to make this extend Phaser.TilemapLayer and get access to its methods in that way, however as this needs to
12+
* extend PIXI.Tilemap, and Phaser.TilemapLayer extends Phaser.DisplayObject. I can't see a way to achieve that merge.
913
*
14+
*
1015
* Since a PIXI.Tilemap is a PIXI.DisplayObjectContainer it can be moved around the display, added to other groups or display objects, etc.
1116
*
1217
* By default TilemapLayers have fixedToCamera set to `true`. Changing this will break Camera follow and scrolling behavior.
@@ -234,17 +239,23 @@ Phaser.TilemapLayerGL = function (game, tilemap, index, width, height) {
234239

235240
Phaser.Component.Core.init.call(this, game, 0, 0, null, null);
236241

237-
// must be called after the Core.init
242+
// must be set *after* the Core.init
238243
this.fixedToCamera = true;
239244
};
240245

246+
247+
// constructor: extends PIXI.Tilemap
241248
Phaser.TilemapLayerGL.prototype = Object.create(PIXI.Tilemap.prototype);
242249
Phaser.TilemapLayerGL.prototype.constructor = Phaser.TilemapLayerGL;
243250

251+
252+
// only one Phaser component used
244253
Phaser.Component.Core.install.call(Phaser.TilemapLayerGL.prototype, [
245254
'FixedToCamera'
246255
]);
247256

257+
258+
// redirect method prototypes (TODO: not needed? I'm not sure...)
248259
Phaser.TilemapLayerGL.prototype.preUpdateCore = Phaser.Component.Core.preUpdate;
249260
Phaser.TileSprite.prototype.preUpdatePhysics = Phaser.Component.PhysicsBody.preUpdate;
250261
Phaser.TileSprite.prototype.preUpdateLifeSpan = Phaser.Component.LifeSpan.preUpdate;
@@ -706,45 +717,17 @@ Phaser.TilemapLayerGL.prototype.renderRegion = function (scrollX, scrollY, left,
706717

707718
var index = tile.index;
708719

709-
// if (tile.alpha !== lastAlpha && !this.debug)
710-
// {
711-
// //context.globalAlpha = tile.alpha;
712-
// lastAlpha = tile.alpha;
713-
// }
714-
715720
if (tile.rotation || tile.flipped)
716721
{
717-
//context.save();
718-
//context.translate(tx + tile.centerX, ty + tile.centerY);
719-
//context.rotate(tile.rotation);
720-
721-
// if (tile.flipped)
722-
// {
723-
// context.scale(-1, 1);
724-
// }
725-
726722
this._mc.tileset.drawGl(this.glBatch, -tile.centerX + offx, -tile.centerY + offy, index, tile.alpha);
727-
//context.restore();
728723
}
729724
else
730725
{
731726
this._mc.tileset.drawGl(this.glBatch, tx + offx, ty + offy, index, tile.alpha);
732727
}
733-
// if (!this._mc.tileset && this.debugSettings.missingImageFill)
734-
// {
735-
// context.fillStyle = this.debugSettings.missingImageFill;
736-
// context.fillRect(tx, ty, tw, th);
737-
// }
738-
739-
// if (tile.debug && this.debugSettings.debuggedTileOverfill)
740-
// {
741-
// context.fillStyle = this.debugSettings.debuggedTileOverfill;
742-
// context.fillRect(tx, ty, tw, th);
743-
// }
744-
745728
}
746729

747-
// at end of each row, add a degenerate marker into the batch list
730+
// at end of each row, add a degenerate marker into the batch drawing list
748731
this._mc.tileset.addDegenerate( this.glBatch );
749732
}
750733

0 commit comments

Comments
 (0)