Add auto hide timer for ability bar
This commit is contained in:
parent
88de47d8d8
commit
093b95df41
|
@ -9,6 +9,8 @@ export class Phase {
|
|||
|
||||
start() {
|
||||
console.log(`%cStart Phase ${this.constructor.name}`, 'color:green;');
|
||||
if (this.scene.abilityBar.shown)
|
||||
this.scene.abilityBar.resetAutoHideTimer();
|
||||
}
|
||||
|
||||
end() {
|
||||
|
|
|
@ -12,6 +12,7 @@ export default class AbilityBar extends Phaser.GameObjects.Container {
|
|||
private abilityNameText: Phaser.GameObjects.Text;
|
||||
|
||||
private tween: Phaser.Tweens.Tween;
|
||||
private autoHideTimer: number;
|
||||
|
||||
public shown: boolean;
|
||||
|
||||
|
@ -55,7 +56,10 @@ export default class AbilityBar extends Phaser.GameObjects.Container {
|
|||
x: shownX,
|
||||
duration: 500,
|
||||
ease: 'Sine.easeOut',
|
||||
onComplete: () => this.tween = null
|
||||
onComplete: () => {
|
||||
this.tween = null;
|
||||
this.resetAutoHideTimer();
|
||||
}
|
||||
});
|
||||
|
||||
this.setVisible(true);
|
||||
|
@ -66,6 +70,9 @@ export default class AbilityBar extends Phaser.GameObjects.Container {
|
|||
if (!this.shown)
|
||||
return;
|
||||
|
||||
if (this.autoHideTimer)
|
||||
clearInterval(this.autoHideTimer);
|
||||
|
||||
if (this.tween)
|
||||
this.tween.stop();
|
||||
|
||||
|
@ -82,4 +89,13 @@ export default class AbilityBar extends Phaser.GameObjects.Container {
|
|||
|
||||
this.shown = false;
|
||||
}
|
||||
|
||||
resetAutoHideTimer(): void {
|
||||
if (this.autoHideTimer)
|
||||
clearInterval(this.autoHideTimer);
|
||||
this.autoHideTimer = setTimeout(() => {
|
||||
this.hide();
|
||||
this.autoHideTimer = null;
|
||||
}, 2500);
|
||||
}
|
||||
}
|
|
@ -13,7 +13,7 @@ export default class TitleUiHandler extends OptionSelectUiHandler {
|
|||
private splashMessage: string;
|
||||
private splashMessageText: Phaser.GameObjects.Text;
|
||||
|
||||
private titleStatsTimer;
|
||||
private titleStatsTimer: number;
|
||||
|
||||
constructor(scene: BattleScene, mode: Mode = Mode.TITLE) {
|
||||
super(scene, mode);
|
||||
|
|
Loading…
Reference in New Issue