A sprite sheet animation plugin for bevy
SpriteSheetAnimation component to automatically update the indices of the TextureAtlasSprite in the same entityRepeat or OncePlay component is present in the entity
Play component to pause/resume an animation```rust fn main() { App::build() .addplugins(DefaultPlugins) .addplugin(AnimationPlugin) // <-- Add the plugin .addstartupsystem(spawn.system()) .run(); }
fn spawn(
mut commands: Commands,
assetserver: Res
// Create an animation // Here we use an index-range (from 0 to 4) where each frame has the same duration let animationhandle = animations.add(SpriteSheetAnimation::fromrange( 0..=4, Duration::from_millis(100), ));
commands // Spawn a bevy sprite-sheet .spawnbundle(SpriteSheetBundle { textureatlas: textures.add(TextureAtlas::fromgrid(assetserver.load("coin.png"), Vec2::new(16.0, 16.0), 5, 1)), transform: Transform::fromscale(Vec3::splat(10.0)), ..Default::default() }) // Insert the asset handle of the animation .insert(animationhandle) // Start the animation immediately. Remove this component in order to pause the animation. .insert(Play); } ```
Here is the result:

(Asset by La Red Games - CC0)
For more details see the documentation
Add to Cargo.toml:
toml
benimator = "0.3.1"
warnings (enabled by default). Log warnings in case of incorrect usage detected.| bevy | benimator | |------|------------| | 0.5 | >= 0.1 |
Issues, pull requests are welcome.
It is possible to directly discuss with me (Jomag#2675) via the bevy discord
Licensed under either of
at your option.