Displaying the name of a player above its head (names are not passed through the network yet)

This commit is contained in:
David Négrier
2020-05-01 23:38:09 +02:00
parent 42ddd8b858
commit 0c04d4305b
4 changed files with 24 additions and 11 deletions
+9 -9
View File
@@ -6,13 +6,13 @@ import {MessageUserPositionInterface} from "../../Connexion";
import {playAnimation} from "../Player/Animation";
export class NonPlayer extends PlayableCaracter {
isFleeing: boolean = false;
fleeingDirection:any = null //todo create a vector class
constructor(scene: Phaser.Scene, x: number, y: number) {
super(scene, x, y, Textures.Player, 1);
this.setSize(32, 32); //edit the hitbox to better match the caracter model
constructor(scene: Phaser.Scene, x: number, y: number, name: string) {
super(scene, x, y, Textures.Player, name, 1);
this.setSize(32, 32); //edit the hitbox to better match the character model
}
@@ -26,15 +26,15 @@ export class NonPlayer extends PlayableCaracter {
if (this.isFleeing) return;
this.say("Don't touch me!");
this.isFleeing = true;
setTimeout(() => {
this.say("Feww, I escaped.");
this.isFleeing = false
this.fleeingDirection = null
}, 3000);
let vectorX = this.x - player.x;
let vectorX = this.x - player.x;
let vectorY = this.y - player.y;
this.fleeingDirection = {x: vectorX, y: vectorY}
}
}
}