fix egg skip console error (#2284)
This commit is contained in:
parent
e10d67858f
commit
8a1560bfa7
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue