Fix crash when playing weather animation before a trainer battle

pull/2/head
Flashfyre 2023-10-24 08:34:52 -04:00
parent 1fd342aa11
commit d135591b75
1 changed files with 3 additions and 1 deletions

View File

@ -330,7 +330,9 @@ class AnimTimedAddBgEvent extends AnimTimedBgEvent {
moveAnim.bgSprite.setScale(1.25); moveAnim.bgSprite.setScale(1.25);
moveAnim.bgSprite.setAlpha(this.opacity / 255); moveAnim.bgSprite.setAlpha(this.opacity / 255);
scene.field.add(moveAnim.bgSprite); scene.field.add(moveAnim.bgSprite);
scene.field.moveBelow(moveAnim.bgSprite as Phaser.GameObjects.GameObject, scene.getEnemyPokemon() || scene.getPlayerPokemon()); const fieldPokemon = scene.getEnemyPokemon() || scene.getPlayerPokemon();
if (fieldPokemon?.isOnField())
scene.field.moveBelow(moveAnim.bgSprite as Phaser.GameObjects.GameObject, fieldPokemon);
scene.tweens.add({ scene.tweens.add({
targets: moveAnim.bgSprite, targets: moveAnim.bgSprite,