Fix User depth
- Update strategy layers depth - Add depth to manager layers positions between all users
This commit is contained in:
parent
c59d693f6e
commit
59127534ac
4 changed files with 37 additions and 33 deletions
|
@ -48,6 +48,7 @@ export class PlayableCaracter extends Phaser.Physics.Arcade.Sprite {
|
|||
this.setCollideWorldBounds(true);
|
||||
this.setSize(16, 16); //edit the hitbox to better match the caracter model
|
||||
this.setOffset(8, 16);
|
||||
this.setDepth(-1);
|
||||
}
|
||||
|
||||
move(x: number, y: number) {
|
||||
|
@ -69,6 +70,9 @@ export class PlayableCaracter extends Phaser.Physics.Arcade.Sprite {
|
|||
this.bubble.moveBubble(this.x, this.y);
|
||||
}
|
||||
this.updatePlayerNamePosition(this.x, this.y);
|
||||
|
||||
//update depth user
|
||||
this.setDepth(this.y);
|
||||
}
|
||||
|
||||
updatePlayerNamePosition(x: number, y: number){
|
||||
|
|
|
@ -96,15 +96,11 @@ export class GameScene extends Phaser.Scene implements GameSceneInterface{
|
|||
this.Layers = new Array<Phaser.Tilemaps.StaticTilemapLayer>();
|
||||
let depth = -2;
|
||||
this.map.layers.forEach((layer) => {
|
||||
if (layer.type === 'tilelayer' && layer.name === "override") {
|
||||
let tab : Array<any> = (layer.properties as any);
|
||||
let propertiesDepth = tab.find((props : any) => props.name === "depth");
|
||||
this.addLayer( this.Map.createStaticLayer(layer.name, this.Terrains, 0, 0).setDepth(propertiesDepth ? propertiesDepth.value : 2) );
|
||||
if (layer.type === 'tilelayer') {
|
||||
this.addLayer(this.Map.createStaticLayer(layer.name, this.Terrains, 0, 0).setDepth(depth));
|
||||
}
|
||||
else if (layer.type === 'tilelayer') {
|
||||
this.addLayer( this.Map.createStaticLayer(layer.name, this.Terrains, 0, 0).setDepth(depth) );
|
||||
} else if (layer.type === 'objectgroup' && layer.name === 'floorLayer') {
|
||||
depth = -1;
|
||||
if (layer.type === 'objectgroup' && layer.name === 'floorLayer') {
|
||||
depth = 10000;
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -41,7 +41,6 @@ export class Player extends PlayableCaracter implements CurrentGamerInterface, G
|
|||
//set data
|
||||
this.userId = userId;
|
||||
|
||||
|
||||
//the current player model should be push away by other players to prevent conflict
|
||||
this.setImmovable(false);
|
||||
}
|
||||
|
@ -102,6 +101,7 @@ export class Player extends PlayableCaracter implements CurrentGamerInterface, G
|
|||
playAnimation(this, MessageUserPosition.position.direction);
|
||||
this.setX(MessageUserPosition.position.x);
|
||||
this.setY(MessageUserPosition.position.y);
|
||||
this.setDepth(MessageUserPosition.position.y);
|
||||
this.updatePlayerNamePosition(MessageUserPosition.position.x, MessageUserPosition.position.y);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue