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) {
|
if (!this.canSkip || this.skipped) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (this.eggCounterContainer.eggCountText?.data === undefined) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
this.skipped = true;
|
this.skipped = true;
|
||||||
if (!this.hatched) {
|
if (!this.hatched) {
|
||||||
this.doHatch();
|
this.doHatch();
|
||||||
|
|
|
@ -17,7 +17,7 @@ export default class EggCounterContainer extends Phaser.GameObjects.Container {
|
||||||
private battleScene: BattleScene;
|
private battleScene: BattleScene;
|
||||||
private eggCount: integer;
|
private eggCount: integer;
|
||||||
private eggCountWindow: Phaser.GameObjects.NineSlice;
|
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.
|
* @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);
|
eggSprite.setScale(0.32);
|
||||||
|
|
||||||
this.eggCountText = addTextObject(this.battleScene, 28, 13, `${this.eggCount}`, TextStyle.MESSAGE, { fontSize: "66px" });
|
this.eggCountText = addTextObject(this.battleScene, 28, 13, `${this.eggCount}`, TextStyle.MESSAGE, { fontSize: "66px" });
|
||||||
|
this.eggCountText.setName("text-egg-count");
|
||||||
|
|
||||||
this.add(eggSprite);
|
this.add(eggSprite);
|
||||||
this.add(this.eggCountText);
|
this.add(this.eggCountText);
|
||||||
|
@ -69,7 +70,7 @@ export default class EggCounterContainer extends Phaser.GameObjects.Container {
|
||||||
*/
|
*/
|
||||||
private onEggCountChanged(event: Event): void {
|
private onEggCountChanged(event: Event): void {
|
||||||
const eggCountChangedEvent = event as EggCountChangedEvent;
|
const eggCountChangedEvent = event as EggCountChangedEvent;
|
||||||
if (!eggCountChangedEvent) {
|
if (!eggCountChangedEvent || !this.eggCountText?.data) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue