From fb35075b01bccb78a0997206bd83e47d5d8862b7 Mon Sep 17 00:00:00 2001 From: Dorian Date: Sat, 11 Apr 2026 20:17:10 +0100 Subject: [PATCH] =?UTF-8?q?fix:=20arcade=20mode=20crash=20=E2=80=94=20kapl?= =?UTF-8?q?ay=20go()=20defers=20scene=20init=20to=20next=20frame?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit k.go('arcade') schedules the scene callback on frameEnd, not synchronously. start() was called before fighters existed, causing "Cannot read properties of undefined (reading 'obj')". Fix: await a readiness promise that resolves once the scene callback has created the fighters. Co-Authored-By: Claude Opus 4.6 --- frontend/src/components/ArcadeViewer.vue | 4 ++-- frontend/src/game/ArcadeScene.ts | 11 ++++++++++- frontend/src/game/arcade/types.ts | 2 +- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/frontend/src/components/ArcadeViewer.vue b/frontend/src/components/ArcadeViewer.vue index e39a128..f274ef7 100644 --- a/frontend/src/components/ArcadeViewer.vue +++ b/frontend/src/components/ArcadeViewer.vue @@ -151,12 +151,12 @@ async function initScene(): Promise { comboTimer = setTimeout(() => { comboInfo.value = null }, 1200) }) - // Start + // Start (awaits scene readiness — kaplay defers scene init to next frame) showAnnouncement('ROUND 1', 1200) setTimeout(() => { showAnnouncement('FIGHT!', 800) }, 1300) - scene.start() + await scene.start() // Start input polling inputPollId = requestAnimationFrame(pollInput) diff --git a/frontend/src/game/ArcadeScene.ts b/frontend/src/game/ArcadeScene.ts index b15d98d..23775b3 100644 --- a/frontend/src/game/ArcadeScene.ts +++ b/frontend/src/game/ArcadeScene.ts @@ -156,6 +156,11 @@ export async function createArcadeScene(config: ArcadeConfig): Promise void + const sceneReadyPromise = new Promise(resolve => { sceneReady = resolve }) + // ═══════════════════════════════════════════════════════════════ // Scene Setup // ═══════════════════════════════════════════════════════════════ @@ -180,6 +185,9 @@ export async function createArcadeScene(config: ArcadeConfig): Promise void + start: () => Promise pause: () => void resume: () => void destroy: () => void