move twemoji menu to svelte

This commit is contained in:
Lurkars 2021-09-10 16:57:21 +02:00
parent b50253a529
commit e553392d9d
7 changed files with 132 additions and 138 deletions

View file

@ -282,50 +282,55 @@ export abstract class Character extends Container {
super.destroy();
}
playEmote(emote: string) {
this.cancelPreviousEmote();
const scalingFactor = waScaleManager.uiScalingFactor;
const emoteY = -60;
this.playerName.setVisible(false);
this.emote = new Text(this.scene, -12, 0, emote, { fontFamily: '"Twemoji Mozilla"', fontSize: "24px" });
this.emote.setAlpha(0);
this.add(this.emote);
this.createStartTransition(scalingFactor, emoteY);
isSilent() {
isSilentStore.set(true);
}
noSilent() {
isSilentStore.set(false);
}
private createStartTransition(scalingFactor: number, emoteY: number) {
playEmote(emote: string) {
this.cancelPreviousEmote();
const emoteY = -45;
this.playerName.setVisible(false);
this.emote = new Text(this.scene, -10, 0, emote, { fontFamily: '"twemoji"', fontSize: "20px" });
this.emote.setAlpha(0);
this.add(this.emote);
this.createStartTransition(emoteY);
}
private createStartTransition(emoteY: number) {
this.emoteTween = this.scene?.tweens.add({
targets: this.emote,
props: {
scale: scalingFactor,
alpha: 1,
y: emoteY,
},
ease: "Power2",
duration: 500,
onComplete: () => {
this.startPulseTransition(emoteY, scalingFactor);
this.startPulseTransition(emoteY);
},
});
}
private startPulseTransition(emoteY: number, scalingFactor: number) {
this.emoteTween = this.scene?.tweens.add({
targets: this.emote,
props: {
y: emoteY * 1.3,
scale: scalingFactor * 1.1,
},
duration: 250,
yoyo: true,
repeat: 1,
completeDelay: 200,
onComplete: () => {
this.startExitTransition(emoteY);
},
});
private startPulseTransition(emoteY: number) {
if (this.emote) {
this.emoteTween = this.scene?.tweens.add({
targets: this.emote,
props: {
y: emoteY * 1.3,
scale: this.emote.scale * 1.1,
},
duration: 250,
yoyo: true,
repeat: 1,
completeDelay: 200,
onComplete: () => {
this.startExitTransition(emoteY);
},
});
}
}
private startExitTransition(emoteY: number) {