fix egg skip console error (#2284)

This commit is contained in:
Matthew 2024-06-16 00:48:09 -04:00 committed by GitHub
parent e10d67858f
commit 8a1560bfa7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 2 deletions

View File

@ -262,6 +262,9 @@ export class EggHatchPhase extends Phase {
if (!this.canSkip || this.skipped) {
return false;
}
if (this.eggCounterContainer.eggCountText?.data === undefined) {
return false;
}
this.skipped = true;
if (!this.hatched) {
this.doHatch();

View File

@ -17,7 +17,7 @@ export default class EggCounterContainer extends Phaser.GameObjects.Container {
private battleScene: BattleScene;
private eggCount: integer;
private eggCountWindow: Phaser.GameObjects.NineSlice;
private eggCountText: Phaser.GameObjects.Text;
public eggCountText: Phaser.GameObjects.Text;
/**
* @param {BattleScene} scene - The scene to which this container belongs.
@ -49,6 +49,7 @@ export default class EggCounterContainer extends Phaser.GameObjects.Container {
eggSprite.setScale(0.32);
this.eggCountText = addTextObject(this.battleScene, 28, 13, `${this.eggCount}`, TextStyle.MESSAGE, { fontSize: "66px" });
this.eggCountText.setName("text-egg-count");
this.add(eggSprite);
this.add(this.eggCountText);
@ -69,7 +70,7 @@ export default class EggCounterContainer extends Phaser.GameObjects.Container {
*/
private onEggCountChanged(event: Event): void {
const eggCountChangedEvent = event as EggCountChangedEvent;
if (!eggCountChangedEvent) {
if (!eggCountChangedEvent || !this.eggCountText?.data) {
return;
}