#How to update sprite animations having different amount of frames?

3 messages · Page 1 of 1 (latest)

rough cradle
#

So, I have a spritesheet having different animations of the player
My code basically updates the sprite index for animation and resets back to zero if the index becomes greater than max frames,
This logic works fine for aniamtions having same amount of frame count(like idle and walk)
but gives index doesn't exist for shorter animations(like attack which has just 4 frames)

This is the player code:

#

also would be great on some insights as to a good way to switching animations
since currently this is what is I am doing
*atlas = asset.attack_front.clone();

viral viper
#

I've been using an Animation component with both a Timer and frames: Range<usize> , then mapping eg. player idle to animation.frames = 0..6