mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-12-16 14:55:22 +01:00
* Removed unused scale parameter from InfoOverlay s * Using `globalScene.scaledCanvas.width` * Using `scaledCanvas` everywhere * Replaced some sneaky instances of `scaledCanvas / 2` * Convert comments to TSDocs * Fix typo * Caught a few more instances of `width / 6` etc * Fixed unused scale parameter --------- Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> Co-authored-by: Sirz Benjie <142067137+SirzBenjie@users.noreply.github.com>
81 lines
1.6 KiB
TypeScript
81 lines
1.6 KiB
TypeScript
import { globalScene } from "#app/global-scene";
|
|
import { fixedInt } from "#utils/common";
|
|
|
|
export class SavingIconHandler extends Phaser.GameObjects.Container {
|
|
private icon: Phaser.GameObjects.Sprite;
|
|
|
|
private animActive: boolean;
|
|
private shown: boolean;
|
|
|
|
constructor() {
|
|
super(globalScene, globalScene.scaledCanvas.width - 4, globalScene.scaledCanvas.height - 4);
|
|
}
|
|
|
|
setup(): void {
|
|
this.icon = globalScene.add.sprite(0, 0, "saving_icon");
|
|
this.icon.setOrigin(1, 1);
|
|
|
|
this.add(this.icon);
|
|
|
|
this.animActive = false;
|
|
this.shown = false;
|
|
|
|
this.setAlpha(0);
|
|
this.setVisible(false);
|
|
}
|
|
|
|
show(): void {
|
|
this.shown = true;
|
|
|
|
if (this.animActive) {
|
|
return;
|
|
}
|
|
|
|
this.animActive = true;
|
|
|
|
globalScene.tweens.add({
|
|
targets: this,
|
|
alpha: 1,
|
|
duration: fixedInt(250),
|
|
ease: "Sine.easeInOut",
|
|
onComplete: () => {
|
|
globalScene.time.delayedCall(fixedInt(500), () => {
|
|
this.animActive = false;
|
|
if (!this.shown) {
|
|
this.hide();
|
|
}
|
|
});
|
|
},
|
|
});
|
|
|
|
this.setVisible(true);
|
|
this.shown = true;
|
|
}
|
|
|
|
hide(): void {
|
|
this.shown = false;
|
|
|
|
if (this.animActive) {
|
|
return;
|
|
}
|
|
|
|
this.animActive = true;
|
|
|
|
globalScene.tweens.add({
|
|
targets: this,
|
|
alpha: 0,
|
|
duration: fixedInt(250),
|
|
ease: "Sine.easeInOut",
|
|
onComplete: () => {
|
|
this.animActive = false;
|
|
this.setVisible(false);
|
|
if (this.shown) {
|
|
this.show();
|
|
}
|
|
},
|
|
});
|
|
|
|
this.shown = false;
|
|
}
|
|
}
|