Add auto hide timer for ability bar

pull/69/head
Flashfyre 2024-04-09 12:08:38 -04:00
parent 88de47d8d8
commit 093b95df41
3 changed files with 20 additions and 2 deletions

View File

@ -9,6 +9,8 @@ export class Phase {
start() { start() {
console.log(`%cStart Phase ${this.constructor.name}`, 'color:green;'); console.log(`%cStart Phase ${this.constructor.name}`, 'color:green;');
if (this.scene.abilityBar.shown)
this.scene.abilityBar.resetAutoHideTimer();
} }
end() { end() {

View File

@ -12,6 +12,7 @@ export default class AbilityBar extends Phaser.GameObjects.Container {
private abilityNameText: Phaser.GameObjects.Text; private abilityNameText: Phaser.GameObjects.Text;
private tween: Phaser.Tweens.Tween; private tween: Phaser.Tweens.Tween;
private autoHideTimer: number;
public shown: boolean; public shown: boolean;
@ -55,7 +56,10 @@ export default class AbilityBar extends Phaser.GameObjects.Container {
x: shownX, x: shownX,
duration: 500, duration: 500,
ease: 'Sine.easeOut', ease: 'Sine.easeOut',
onComplete: () => this.tween = null onComplete: () => {
this.tween = null;
this.resetAutoHideTimer();
}
}); });
this.setVisible(true); this.setVisible(true);
@ -66,6 +70,9 @@ export default class AbilityBar extends Phaser.GameObjects.Container {
if (!this.shown) if (!this.shown)
return; return;
if (this.autoHideTimer)
clearInterval(this.autoHideTimer);
if (this.tween) if (this.tween)
this.tween.stop(); this.tween.stop();
@ -82,4 +89,13 @@ export default class AbilityBar extends Phaser.GameObjects.Container {
this.shown = false; this.shown = false;
} }
resetAutoHideTimer(): void {
if (this.autoHideTimer)
clearInterval(this.autoHideTimer);
this.autoHideTimer = setTimeout(() => {
this.hide();
this.autoHideTimer = null;
}, 2500);
}
} }

View File

@ -13,7 +13,7 @@ export default class TitleUiHandler extends OptionSelectUiHandler {
private splashMessage: string; private splashMessage: string;
private splashMessageText: Phaser.GameObjects.Text; private splashMessageText: Phaser.GameObjects.Text;
private titleStatsTimer; private titleStatsTimer: number;
constructor(scene: BattleScene, mode: Mode = Mode.TITLE) { constructor(scene: BattleScene, mode: Mode = Mode.TITLE) {
super(scene, mode); super(scene, mode);