DEV Community

Calin Baenen
Calin Baenen

Posted on

I now have an animated sprite!

So recently I've been working on refining the texture-handling system for my game, RuntDeale.
But, I finished polishing it (for now), so I ended up trying to do something a little more fancy for my next test-drive.

So, since I'm new to using Bevy and I don't know how much I truly understand, I decided to make a test "system" called speeen to test out how I could write a system for changing what the player looks like.
The function, in the words of Ceave Gaming, was "surprisingly simple", to make. Only five lines are used in the body.

/// Makes the player SPEEEEEEEEEEN.
pub fn speeen(
    mut spin_delay:ResMut<Timer>,
    mut player:Query<&mut TextureAtlasSprite, With<Player>>,
    time:Res<Time>
) {
    spin_delay.tick(time.delta());
    if spin_delay.just_finished() {
        for mut sprite in player.iter_mut() {
            sprite.index = (sprite.index+1) % 4;
        }
    }
}
Enter fullscreen mode Exit fullscreen mode

Anyways,
if you want to check out the test or leave feedback on my game, I'd greatly appreciate it.

Thanks for reading!
Cheers!

Top comments (0)