mirror of
https://github.com/nacabaro/vbhelper.git
synced 2026-06-05 22:02:54 +00:00
Added Digimon idle animation.
This commit is contained in:
parent
37e5efa874
commit
9f7e452850
@ -56,6 +56,22 @@ class DigimonAnimationStateMachine(
|
|||||||
DigimonAnimationType.FLEE to 11
|
DigimonAnimationType.FLEE to 11
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Animation frame sequences - defines which frames to cycle through for each animation
|
||||||
|
private val animationFrameSequences = mapOf(
|
||||||
|
DigimonAnimationType.IDLE to listOf(0, 1), // Cycle between idle frames
|
||||||
|
DigimonAnimationType.IDLE2 to listOf(1, 0), // Alternative idle cycle
|
||||||
|
DigimonAnimationType.WALK to listOf(2, 3), // Walk animation frames
|
||||||
|
DigimonAnimationType.WALK2 to listOf(3, 2), // Alternative walk cycle
|
||||||
|
DigimonAnimationType.RUN to listOf(4, 5), // Run animation frames
|
||||||
|
DigimonAnimationType.RUN2 to listOf(5, 4), // Alternative run cycle
|
||||||
|
DigimonAnimationType.WORKOUT to listOf(6, 7), // Workout animation frames
|
||||||
|
DigimonAnimationType.WORKOUT2 to listOf(7, 6), // Alternative workout cycle
|
||||||
|
DigimonAnimationType.HAPPY to listOf(8), // Single happy frame
|
||||||
|
DigimonAnimationType.SLEEP to listOf(9), // Single sleep frame
|
||||||
|
DigimonAnimationType.ATTACK to listOf(10), // Single attack frame
|
||||||
|
DigimonAnimationType.FLEE to listOf(11) // Single flee frame
|
||||||
|
)
|
||||||
|
|
||||||
// Animation durations for each type
|
// Animation durations for each type
|
||||||
private val animationDurations = mapOf(
|
private val animationDurations = mapOf(
|
||||||
DigimonAnimationType.IDLE to 500L,
|
DigimonAnimationType.IDLE to 500L,
|
||||||
@ -80,21 +96,21 @@ class DigimonAnimationStateMachine(
|
|||||||
currentAnimation = animationType
|
currentAnimation = animationType
|
||||||
isPlaying = true
|
isPlaying = true
|
||||||
|
|
||||||
val spriteIndex = animationMapping[animationType] ?: 0
|
val frameSequence = animationFrameSequences[animationType] ?: listOf(0)
|
||||||
currentSpriteIndex = spriteIndex
|
|
||||||
|
|
||||||
val duration = animationDurations[animationType] ?: 100L
|
val duration = animationDurations[animationType] ?: 100L
|
||||||
|
|
||||||
// For non-looping animations like ATTACK, play once and return to IDLE
|
// For non-looping animations like ATTACK, play once and return to IDLE
|
||||||
if (animationType == DigimonAnimationType.ATTACK) {
|
if (animationType == DigimonAnimationType.ATTACK) {
|
||||||
|
currentSpriteIndex = frameSequence[0]
|
||||||
delay(duration)
|
delay(duration)
|
||||||
playAnimation(DigimonAnimationType.IDLE)
|
playAnimation(DigimonAnimationType.IDLE)
|
||||||
} else {
|
} else {
|
||||||
// For looping animations, keep playing
|
// For looping animations, cycle through frames
|
||||||
|
var frameIndex = 0
|
||||||
while (isPlaying && currentAnimation == animationType) {
|
while (isPlaying && currentAnimation == animationType) {
|
||||||
|
currentSpriteIndex = frameSequence[frameIndex % frameSequence.size]
|
||||||
delay(duration)
|
delay(duration)
|
||||||
// For now, we'll just keep the same sprite
|
frameIndex++
|
||||||
// In the future, we could cycle through multiple sprites for each animation
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user