Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lerouxrgd/bevy_mod_aseprite
A plugin for using Aseprite animations in Bevy
https://github.com/lerouxrgd/bevy_mod_aseprite
Last synced: 3 days ago
JSON representation
A plugin for using Aseprite animations in Bevy
- Host: GitHub
- URL: https://github.com/lerouxrgd/bevy_mod_aseprite
- Owner: lerouxrgd
- License: apache-2.0
- Created: 2022-11-22T22:32:14.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2024-12-23T23:35:31.000Z (10 days ago)
- Last Synced: 2024-12-24T04:20:53.075Z (10 days ago)
- Language: Rust
- Homepage:
- Size: 729 KB
- Stars: 38
- Watchers: 6
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# 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_asepriteA plugin for using [Aseprite][] animations in [Bevy][].
The [`Aseprite`][aseprite-compo] component **requires** Bevy's [`Sprite`][sprite-compo] and
contains two fields:
* asset: [`Handle`][aseprite-asset]
* anim: [`AsepriteAnimation`][aseprite-anim].[bevy]: https://bevyengine.org/
[aseprite]: https://www.aseprite.org/
[sprite-compo]: https://docs.rs/bevy/latest/bevy/sprite/struct.Sprite.html
[aseprite-compo]: https://docs.rs/bevy_mod_aseprite/latest/bevy_mod_aseprite/struct.Aseprite.html
[aseprite-asset]: https://docs.rs/bevy_mod_aseprite/latest/bevy_mod_aseprite/struct.AsepriteAsset.html
[aseprite-anim]: https://docs.rs/bevy_mod_aseprite/latest/bevy_mod_aseprite/struct.AsepriteAnimation.html## 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 ase_handles: ResMut) {
let player = asset_server.load("player.ase");
ase_handles.push(player);
}fn setup(
mut commands: Commands,
ase_handles: Res,
ase_assets: Res>,
) {
let ase_handle = &ase_handles[0];
let ase_asset = ase_assets.get(ase_handle).unwrap();
let anim = AsepriteAnimation::new(ase_asset.info(), "idle");
commands.spawn((
Player,
Sprite {
image: ase_asset.texture().clone_weak(),
texture_atlas: Some(TextureAtlas {
index: anim.current_frame(),
layout: ase_asset.layout().clone_weak(),
}),
..default()
},
Aseprite {
anim,
asset: ase_handle.clone_weak(),
},
));
}#[derive(Resource, Deref, DerefMut, Default)]
struct AsepriteHandles(Vec>);
```The [`AsepriteAnimation`][aseprite-anim] struct also exposes methods to get information
such as the current animation frame (within a tag or not), its duration, and 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## Bevy Compatibility
| **bevy** | **bevy_mod_aseprite** |
|----------|-----------------------|
| 0.15 | 0.9 |
| 0.14 | 0.8 |
| 0.13 | 0.7 |
| 0.12 | 0.6 |
| 0.11 | 0.5 |
| 0.10 | 0.4 |
| 0.9 | 0.2, 0.3 |
| 0.8 | 0.1 |## History
This crate started as a fork of [mdenchev/bevy_aseprite][].
[mdenchev/bevy_aseprite]: https://github.com/mdenchev/bevy_aseprite