mirror of
https://github.com/nacabaro/vbhelper.git
synced 2026-06-05 22:02:54 +00:00
Fixed bug where enemy attack was showing as player attack sprite for a moment before animation.
This commit is contained in:
parent
cfa52bce9b
commit
c5cebd8213
@ -205,6 +205,11 @@ fun PlayerBattleView(
|
|||||||
opponent: APIBattleCharacter?,
|
opponent: APIBattleCharacter?,
|
||||||
onSetPendingDamage: (Float, Float) -> Unit
|
onSetPendingDamage: (Float, Float) -> Unit
|
||||||
) {
|
) {
|
||||||
|
// Track previous character ID to detect transitions
|
||||||
|
var previousCharacterId by remember { mutableStateOf<String?>(null) }
|
||||||
|
var previousAttackPhase by remember { mutableStateOf<Int?>(null) }
|
||||||
|
var isTransitioning by remember { mutableStateOf(false) }
|
||||||
|
|
||||||
Box(
|
Box(
|
||||||
modifier = Modifier.fillMaxSize()
|
modifier = Modifier.fillMaxSize()
|
||||||
) {
|
) {
|
||||||
@ -293,8 +298,22 @@ fun PlayerBattleView(
|
|||||||
else -> activeCharacter?.charaId ?: "dim011_mon01" // Use player's character ID
|
else -> activeCharacter?.charaId ?: "dim011_mon01" // Use player's character ID
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Handle sprite transition
|
||||||
|
LaunchedEffect(characterId, battleSystem.attackPhase) {
|
||||||
|
if ((previousCharacterId != null && previousCharacterId != characterId) ||
|
||||||
|
(previousAttackPhase != null && previousAttackPhase != battleSystem.attackPhase)) {
|
||||||
|
// Character ID or attack phase changed, start transition
|
||||||
|
isTransitioning = true
|
||||||
|
delay(100) // Brief invisibility period
|
||||||
|
isTransitioning = false
|
||||||
|
}
|
||||||
|
previousCharacterId = characterId
|
||||||
|
previousAttackPhase = battleSystem.attackPhase
|
||||||
|
}
|
||||||
|
|
||||||
println("PlayerBattleView - Attack sprite - Phase: ${battleSystem.attackPhase}, Progress: $attackAnimationProgress, X Offset: $xOffset, CurrentView: ${battleSystem.currentView}")
|
println("PlayerBattleView - Attack sprite - Phase: ${battleSystem.attackPhase}, Progress: $attackAnimationProgress, X Offset: $xOffset, CurrentView: ${battleSystem.currentView}")
|
||||||
|
|
||||||
|
if (!isTransitioning) {
|
||||||
AttackSpriteImage(
|
AttackSpriteImage(
|
||||||
characterId = characterId,
|
characterId = characterId,
|
||||||
isLarge = true,
|
isLarge = true,
|
||||||
@ -310,6 +329,7 @@ fun PlayerBattleView(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Bottom section: Critical bar and Attack button
|
// Bottom section: Critical bar and Attack button
|
||||||
Column(
|
Column(
|
||||||
@ -434,6 +454,11 @@ fun OpponentBattleView(
|
|||||||
activeCharacter: APIBattleCharacter? = null,
|
activeCharacter: APIBattleCharacter? = null,
|
||||||
playerCharacter: APIBattleCharacter? = null
|
playerCharacter: APIBattleCharacter? = null
|
||||||
) {
|
) {
|
||||||
|
// Track previous character ID to detect transitions
|
||||||
|
var previousCharacterId by remember { mutableStateOf<String?>(null) }
|
||||||
|
var previousAttackPhase by remember { mutableStateOf<Int?>(null) }
|
||||||
|
var isTransitioning by remember { mutableStateOf(false) }
|
||||||
|
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxSize()
|
.fillMaxSize()
|
||||||
@ -478,8 +503,22 @@ fun OpponentBattleView(
|
|||||||
else -> "dim011_mon01"
|
else -> "dim011_mon01"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Handle sprite transition
|
||||||
|
LaunchedEffect(characterId, battleSystem.attackPhase) {
|
||||||
|
if ((previousCharacterId != null && previousCharacterId != characterId) ||
|
||||||
|
(previousAttackPhase != null && previousAttackPhase != battleSystem.attackPhase)) {
|
||||||
|
// Character ID or attack phase changed, start transition
|
||||||
|
isTransitioning = true
|
||||||
|
delay(100) // Brief invisibility period
|
||||||
|
isTransitioning = false
|
||||||
|
}
|
||||||
|
previousCharacterId = characterId
|
||||||
|
previousAttackPhase = battleSystem.attackPhase
|
||||||
|
}
|
||||||
|
|
||||||
println("OpponentBattleView - Attack sprite - Phase: ${battleSystem.attackPhase}, Progress: $attackAnimationProgress, X Offset: $xOffset, CurrentView: ${battleSystem.currentView}")
|
println("OpponentBattleView - Attack sprite - Phase: ${battleSystem.attackPhase}, Progress: $attackAnimationProgress, X Offset: $xOffset, CurrentView: ${battleSystem.currentView}")
|
||||||
|
|
||||||
|
if (!isTransitioning) {
|
||||||
AttackSpriteImage(
|
AttackSpriteImage(
|
||||||
characterId = characterId,
|
characterId = characterId,
|
||||||
isLarge = true,
|
isLarge = true,
|
||||||
@ -494,6 +533,7 @@ fun OpponentBattleView(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Enemy HP bar
|
// Enemy HP bar
|
||||||
LinearProgressIndicator(
|
LinearProgressIndicator(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user