# Aseprite plugin for Bevy [![latest]][crates.io] [![doc]][docs.rs] [latest]: https://img.shields.io/crates/v/bevy_mod_aseprite.svg [crates.io]: https://crates.io/crates/bevy_mod_aseprite [doc]: https://docs.rs/bevy_mod_aseprite/badge.svg [docs.rs]: https://docs.rs/bevy_mod_aseprite A plugin for using [Aseprite][] animations in [Bevy][]. The [`AsepriteBundle`][aseprite-bundle] is composed of the same fields as the [`SpriteSheetBundle`][spritesheet-bundle] but with two extra components, [`Handle`][aseprite-handle] and [`AsepriteAnimation`][aseprite-anim]. [bevy]: https://bevyengine.org/ [aseprite]: https://www.aseprite.org/ [spritesheet-bundle]: https://docs.rs/bevy/latest/bevy/prelude/struct.SpriteSheetBundle.html [aseprite-bundle]: https://docs.rs/bevy_mod_aseprite/latest/bevy_mod_aseprite/struct.AsepriteBundle.html [aseprite-handle]: https://docs.rs/bevy_mod_aseprite/latest/bevy_mod_aseprite/struct.Aseprite.html [aseprite-anim]: https://docs.rs/bevy_mod_aseprite/latest/bevy_mod_aseprite/struct.AsepriteAnimation.html ## Example

Aseprite Example

See [examples/aseprite.rs][example-aseprite] for a complete example, you can run it with: ```ignore cargo run --example aseprite ``` [example-aseprite]: https://github.com/lerouxrgd/bevy_mod_aseprite/blob/master/examples/aseprite.rs ## Usage Basic usage is as follows: ```rust,ignore fn load_assets(asset_server: Res, mut aseprite_handles: ResMut) { let player: Handle = asset_server.load("player.ase"); aseprite_handles.push(player); } fn setup( mut commands: Commands, aseprite_handles: Res, aseprites: Res>, ) { let aseprite_handle = &aseprite_handles[0]; let aseprite = aseprites.get(aseprite_handle).unwrap(); let animation = AsepriteAnimation::new(aseprite.info(), "idle"); commands .spawn(Player) .insert(AsepriteBundle { texture: aseprite.texture().clone_weak(), atlas: TextureAtlas { index: animation.current_frame(), layout: aseprite.layout().clone_weak(), }, aseprite: aseprite_handle.clone_weak(), animation, ..default() }); } #[derive(Resource, Deref, DerefMut, Default)] struct AsepriteHandles(Vec>); ``` The component [`AsepriteAnimation`][aseprite-anim] also exposes methods to get information such as the current animation frame (within the tag or not), its duration, or the number of remaining frames. This can be useful to transition states at the end of an animation: ```rust,ignore fn transition_player( time: Res