FEATURE: added the possibility toplay emotes
This commit is contained in:
parent
b57a9957a3
commit
a1d52b4265
23 changed files with 286 additions and 72 deletions
|
@ -5,6 +5,9 @@ import Container = Phaser.GameObjects.Container;
|
|||
import Sprite = Phaser.GameObjects.Sprite;
|
||||
import {TextureError} from "../../Exception/TextureError";
|
||||
import {Companion} from "../Companion/Companion";
|
||||
import {getEmoteAnimName} from "../Game/EmoteManager";
|
||||
|
||||
const playerNameY = - 25;
|
||||
|
||||
interface AnimationData {
|
||||
key: string;
|
||||
|
@ -23,6 +26,7 @@ export abstract class Character extends Container {
|
|||
//private teleportation: Sprite;
|
||||
private invisible: boolean;
|
||||
public companion?: Companion;
|
||||
private emote: Phaser.GameObjects.Sprite | null = null;
|
||||
|
||||
constructor(scene: Phaser.Scene,
|
||||
x: number,
|
||||
|
@ -54,7 +58,7 @@ export abstract class Character extends Container {
|
|||
});
|
||||
this.add(this.teleportation);*/
|
||||
|
||||
this.playerName = new BitmapText(scene, 0, - 25, 'main_font', name, 7);
|
||||
this.playerName = new BitmapText(scene, 0, playerNameY, 'main_font', name, 7);
|
||||
this.playerName.setOrigin(0.5).setCenterAlign().setDepth(99999);
|
||||
this.add(this.playerName);
|
||||
|
||||
|
@ -225,7 +229,23 @@ export abstract class Character extends Container {
|
|||
this.scene.sys.updateList.remove(sprite);
|
||||
}
|
||||
}
|
||||
this.list.forEach(objectContaining => objectContaining.destroy())
|
||||
super.destroy();
|
||||
this.playerName.destroy();
|
||||
}
|
||||
|
||||
playEmote(emoteKey: string) {
|
||||
if (this.emote) return;
|
||||
|
||||
this.playerName.setVisible(false);
|
||||
this.emote = new Sprite(this.scene, 0, -40, emoteKey, 1);
|
||||
this.emote.setDepth(99999);
|
||||
this.add(this.emote);
|
||||
this.scene.sys.updateList.add(this.emote);
|
||||
this.emote.play(getEmoteAnimName(emoteKey));
|
||||
this.emote.on(Phaser.Animations.Events.SPRITE_ANIMATION_COMPLETE, () => {
|
||||
this.emote?.destroy();
|
||||
this.emote = null;
|
||||
this.playerName.setVisible(true);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue