fixes
This commit is contained in:
@@ -87,6 +87,7 @@ function spawnLiveReactionEmoji(key: string) {
|
||||
const showOverlay = computed(() => replayDone.value && !isRequeueing.value && !autoBattle.value)
|
||||
|
||||
let _pageDestroyed = false
|
||||
let _initializingLiveScene = false
|
||||
function sleep(ms: number): Promise<void> {
|
||||
return new Promise((resolve, reject) => {
|
||||
setTimeout(() => {
|
||||
@@ -118,8 +119,11 @@ const tierClass = (t: number) => `tier-${t}`
|
||||
|
||||
// --- Live scene management ---
|
||||
async function initLiveScene() {
|
||||
if (_initializingLiveScene || _pageDestroyed) return
|
||||
_initializingLiveScene = true
|
||||
|
||||
const data = liveFightData.value
|
||||
if (!data?.botA || !data?.botB || !liveCanvas.value) return
|
||||
if (!data?.botA || !data?.botB || !liveCanvas.value) { _initializingLiveScene = false; return }
|
||||
|
||||
if (liveScene) { liveScene.destroy(); liveScene = null }
|
||||
|
||||
@@ -147,6 +151,8 @@ async function initLiveScene() {
|
||||
} catch (err) {
|
||||
console.error('[FightPage] createFightScene failed:', err)
|
||||
liveScene = null
|
||||
} finally {
|
||||
_initializingLiveScene = false
|
||||
}
|
||||
|
||||
liveSceneReady.value = true
|
||||
@@ -167,7 +173,8 @@ async function initLiveScene() {
|
||||
console.warn('[FightPage] entrance failed:', err)
|
||||
}
|
||||
// Safety: ensure fighters are visible after entrance (prevents invisible characters on mobile)
|
||||
liveScene._resetPositions()
|
||||
// Re-check: scene could be destroyed during async playEntrance()
|
||||
liveScene?._resetPositions()
|
||||
setEntrancePlaying(false)
|
||||
}
|
||||
|
||||
@@ -311,7 +318,7 @@ async function handleRoundEnd(data: any) {
|
||||
console.warn('[FightPage] playRound animation failed:', err)
|
||||
}
|
||||
|
||||
if (aWon || bWon) {
|
||||
if (liveScene && (aWon || bWon)) {
|
||||
await liveScene.playTaunt(aWon ? 'a' : 'b')
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user