Benimator

License Crates.io Docs Bevy tracking Build

A sprite sheet animation plugin for bevy

Features

Usage

```rust fn main() { App::new() .addplugins(DefaultPlugins) .addplugin(AnimationPlugin::default()) // <-- Add the plugin .addstartupsystem(spawn) .run(); }

fn spawn( mut commands: Commands, assetserver: Res, mut textures: ResMut>, mut animations: ResMut>, ) { // Don't forget the camera ;-) commands.spawnbundle(OrthographicCameraBundle::new_2d());

// 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:

Example result

(Asset by La Red Games - CC0)

For more details see the documentation

Installation

Add the dependency to your project

sh cargo add benimator

Cargo features

Unstable features

Any API behind one of theses feature flags is unstable, should not be considered complete nor part of the public API. Breaking changes to that API may happen in minor releases

MSRV

The minimum supported rust version is currently: 1.60

It may be increased to a newer stable version in a minor release. (but only if needed)

It will be increased to the latest stable version in a major release. (even if not needed)

Bevy Version Compatibility

| bevy | benimator | |------|-----------| | 0.7 | 3 | | 0.6 | 1, 2 | | 0.5 | 0.1 - 0.3 |

Note: Only the latest published version of benimator is supported

Contribute / Contact

Discussions, issues and pull requests are welcome.

It is possible to directly discuss with me (Jomag#2675) via the bevy discord.

If you want to understand the "architecture" decisions made you may look at the doc/adr directory.

License

Licensed under either of

at your option.