From b7c4eed5aebb97a1215fd3398128263a6ba4c793 Mon Sep 17 00:00:00 2001 From: Paolo Brasolin <paolo.brasolin@eurac.edu> Date: Mon, 4 Apr 2022 13:01:27 +0200 Subject: [PATCH] fix: #fe spawn through internal timer (accounting for pauses) --- frontend/src/js/fight_scene.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/frontend/src/js/fight_scene.ts b/frontend/src/js/fight_scene.ts index 799bdd4..70a4243 100644 --- a/frontend/src/js/fight_scene.ts +++ b/frontend/src/js/fight_scene.ts @@ -356,12 +356,13 @@ export default class FightScene extends Phaser.Scene { } async spawnFoes() { - if (!this.scene.isActive()) return; await this.spawnFoe(); - const delay = - (8 * 1000 * (60 * 1000 - this.time.now)) / 60 / 1000 + 2 * 1000; // TODO: think of a progression which makes sense - setTimeout(this.spawnFoes.bind(this), Math.max(2000, delay)); + const delay = Math.max( + 2000, + (8 * 1000 * (60 * 1000 - this.time.now)) / 60 / 1000 + 2 * 1000, + ); + this.time.delayedCall(delay, this.spawnFoes.bind(this)); } async spawnFoe() { -- GitLab