Merge pull request #97 from moufmouf/fix_player_name_depth

Putting player names depth at a high depth to have them always visible
This commit is contained in:
David Négrier 2020-05-11 19:27:02 +02:00 committed by GitHub
commit 26b2f79914
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -37,7 +37,7 @@ export class PlayableCaracter extends Phaser.Physics.Arcade.Sprite {
this.PlayerValue = name; this.PlayerValue = name;
this.PlayerTexture = texture; this.PlayerTexture = texture;
this.playerName = new BitmapText(scene, x, y - 25, 'main_font', name, 8); this.playerName = new BitmapText(scene, x, y - 25, 'main_font', name, 8);
this.playerName.setOrigin(0.5).setCenterAlign(); this.playerName.setOrigin(0.5).setCenterAlign().setDepth(99999);
scene.add.existing(this.playerName); scene.add.existing(this.playerName);
this.scene.sys.updateList.add(this); this.scene.sys.updateList.add(this);
@ -46,7 +46,7 @@ export class PlayableCaracter extends Phaser.Physics.Arcade.Sprite {
this.scene.physics.world.enableBody(this); this.scene.physics.world.enableBody(this);
this.setImmovable(true); this.setImmovable(true);
this.setCollideWorldBounds(true); this.setCollideWorldBounds(true);
this.setSize(16, 16); //edit the hitbox to better match the caracter model this.setSize(16, 16); //edit the hitbox to better match the character model
this.setOffset(8, 16); this.setOffset(8, 16);
this.setDepth(-1); this.setDepth(-1);
} }
@ -55,7 +55,7 @@ export class PlayableCaracter extends Phaser.Physics.Arcade.Sprite {
this.setVelocity(x, y); this.setVelocity(x, y);
//up or down animationss are prioritized over left and right // up or down animations are prioritized over left and right
if (this.body.velocity.y < 0) { //moving up if (this.body.velocity.y < 0) { //moving up
this.play(`${this.PlayerTexture}-${PlayerAnimationNames.WalkUp}`, true); this.play(`${this.PlayerTexture}-${PlayerAnimationNames.WalkUp}`, true);
} else if (this.body.velocity.y > 0) { //moving down } else if (this.body.velocity.y > 0) { //moving down