Skip to content

Commit e000879

Browse files
committed
Prepare Phaser.Tilemap for testing other examples/tilemaps with the TilemapLayerGL code.
Ensure that TilemapLayerGL is treated as a valid layer the same as TilemapLayer. TODO: I've hardwired the PIXI TilemapLayerGL test flag (pixiTest) to be 'on' unless otherwise specified... need to turn this off before final commits!
1 parent a98d0e8 commit e000879

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

src/tilemap/Tilemap.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,7 @@ Phaser.Tilemap.prototype = {
569569

570570
// Add Buffer support for the left of the canvas
571571

572+
if (pixiTest === undefined) { pixiTest = true; } // TODO: disable test of TilemapLayerGL unless requested
572573
if (width === undefined) { width = this.game.width; }
573574
if (height === undefined) { height = this.game.height; }
574575
if (group === undefined) { group = this.game.world; }
@@ -607,8 +608,9 @@ Phaser.Tilemap.prototype = {
607608
* @param {Phaser.Group} [group] - Optional Group to add the layer to. If not specified it will be added to the World group.
608609
* @return {Phaser.TilemapLayer} The TilemapLayer object. This is an extension of Phaser.Image and can be moved around the display list accordingly.
609610
*/
610-
createBlankLayer: function (name, width, height, tileWidth, tileHeight, group) {
611+
createBlankLayer: function (name, width, height, tileWidth, tileHeight, group, pixiTest) {
611612

613+
if (pixiTest === undefined) { pixiTest = true; } // TODO: disable test of TilemapLayerGL unless requested
612614
if (group === undefined) { group = this.game.world; }
613615

614616
if (this.getLayerIndex(name) !== null)
@@ -671,7 +673,15 @@ Phaser.Tilemap.prototype = {
671673
h = this.game.height;
672674
}
673675

674-
var output = new Phaser.TilemapLayer(this.game, this, this.layers.length - 1, w, h);
676+
var output;
677+
if ( pixiTest )
678+
{
679+
output = new Phaser.TilemapLayerGL(this.game, this, this.layers.length - 1, w, h);
680+
}
681+
else
682+
{
683+
output = new Phaser.TilemapLayer(this.game, this, this.layers.length - 1, w, h);
684+
}
675685
output.name = name;
676686

677687
return group.add(output);
@@ -1000,6 +1010,10 @@ Phaser.Tilemap.prototype = {
10001010
{
10011011
layer = layer.index;
10021012
}
1013+
else if (layer instanceof Phaser.TilemapLayerGL)
1014+
{
1015+
layer = layer.index;
1016+
}
10031017

10041018
return layer;
10051019

0 commit comments

Comments
 (0)