fixed depth for interactive layers

This commit is contained in:
Johannes Berthel 2021-04-07 00:28:02 +02:00 committed by Thomas Basler
parent 1f7a3880bf
commit 4f3e0f9921
2 changed files with 10 additions and 4 deletions

View File

@ -142,6 +142,7 @@ export class GameScene extends DirtyScene implements CenterListener {
MapPlayersByKey : Map<number, RemotePlayer> = new Map<number, RemotePlayer>();
Map!: Phaser.Tilemaps.Tilemap;
Layers!: Array<Phaser.Tilemaps.TilemapLayer>;
interactiveLayers!: Array<InteractiveLayer>;
Objects!: Array<Phaser.Physics.Arcade.Sprite>;
mapFile!: ITiledMap;
groups: Map<number, Sprite>;
@ -416,6 +417,8 @@ export class GameScene extends DirtyScene implements CenterListener {
//add layer on map
this.Layers = new Array<Phaser.Tilemaps.TilemapLayer>();
this.interactiveLayers = new Array<InteractiveLayer>();
let depth = -2;
for (const layer of this.gameMap.layersIterator) {
if (layer.type === 'tilelayer') {
@ -431,7 +434,7 @@ export class GameScene extends DirtyScene implements CenterListener {
this.loadNextGame(exitUrl);
}
} else {
this.addInteractiveLayer(layer);
this.addInteractiveLayer(this.createInteractiveLayer(layer).setDepth(depth));
}
}
if (layer.type === 'objectgroup' && layer.name === 'floorLayer') {
@ -1147,8 +1150,12 @@ ${escapedMessage}
this.Layers.push(Layer);
}
addInteractiveLayer(layer: ITiledMapLayer): void {
new InteractiveLayer(this, layer);
createInteractiveLayer(layer: ITiledMapLayer): InteractiveLayer {
return new InteractiveLayer(this, layer);
}
addInteractiveLayer(layer: InteractiveLayer): void {
this.interactiveLayers.push(layer);
}
createCollisionWithPlayer() {

View File

@ -34,7 +34,6 @@ export class InteractiveLayer extends Container {
this.updateListener = this.update.bind(this);
scene.events.addListener("update", this.updateListener);
this.setDepth(-2);
this.scene.add.existing(this);
}