[Bug] Prevent game from hanging when loading in a new battle (#5676)
This commit is contained in:
parent
b2bab46e1c
commit
45a2f42602
|
@ -840,12 +840,17 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||
|
||||
await Promise.allSettled(loadPromises);
|
||||
|
||||
// Wait for the assets we queued to load to finish loading, then...
|
||||
// This must be initiated before we queue loading, otherwise the load could have finished before
|
||||
// we reach the line of code that adds the listener, causing a deadlock.
|
||||
const waitOnLoadPromise = new Promise<void>(resolve => globalScene.load.once(Phaser.Loader.Events.COMPLETE, resolve));
|
||||
|
||||
if (!globalScene.load.isLoading()) {
|
||||
globalScene.load.start();
|
||||
}
|
||||
|
||||
// Wait for the assets we queued to load to finish loading, then...
|
||||
// See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Using_promises#creating_a_promise_around_an_old_callback_api
|
||||
await new Promise(resolve => globalScene.load.once(Phaser.Loader.Events.COMPLETE, resolve));
|
||||
await waitOnLoadPromise;
|
||||
|
||||
// With the sprites loaded, generate the animation frame information
|
||||
if (this.isPlayer()) {
|
||||
|
|
Loading…
Reference in New Issue