Crates.io | bevy_asepritesheet |
lib.rs | bevy_asepritesheet |
version | 0.6.0 |
source | src |
created_at | 2023-10-26 23:45:12.656119 |
updated_at | 2024-02-23 07:05:29.306554 |
description | Allow use of animated exported asetprite sprite sheets in bevy game engine |
homepage | https://technostalgic.tech/ |
repository | https://gitlab.com/Technostalgic/bevy_asepritesheet |
max_upload_size | |
id | 1015407 |
size | 1,232,306 |
Bevy Asepritesheet is an asset loader and parser for Bevy game engine. Bevy Asepritesheet processes json spritesheet files exported by Aseprite software. It also has components and systems for building and managing animated sprite entities in the game engine.
Bevy Asepritesheet is capable of parsing spritesheets that look like this into distinct animations based on the aseprite json data.
If set to "Hash", it will not work!
Bevy Asepritesheet supports most features that aseprite exports as json data alongside your spritesheets. Here is a list of Aseprite features that are exported and whether they are supported in Bevy Asepritesheet or not:
Key:
✅ - fully supported and implementated
❌ - not supported
Aseprite Features:
bevy_asepritesheet | bevy | aseprite |
---|---|---|
0.6.x | 0.13 | 1.3.4 |
0.5.x | 0.12 | 1.3.2 |
0.4.x | 0.12 | 1.3.2 |
0.3.x | 0.12 | 1.2.40 |
0.2.x | 0.11 | 1.2.40 |
First, you'll need to add the dependency to Cargo.toml
:
[dependencies]
bevy_aseprite = "0.5"
Then, you will need to add the plugin to your bevy app:
use bevy::prelude::*;
use bevy_asepritesheet::prelude::*;
fn main() {
App::new()
.add_plugins(( DefaultPlugins.set(ImagePlugin::default_nearest()),
AsepritesheetPlugin::new(&["sprite.json"]),
))
.add_systems(Startup, setup)
.run();
}
Then you can just load the spritesheet and spawn in an AnimatedSpriteBundle
with the handle to
start animating your sprite, that's it!
fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
// spawn the camera so we can see the sprite
commands.spawn(Camera2dBundle::default());
// load the spritesheet and get it's handle
let sheet_handle = load_spritesheet(
&mut commands,
&asset_server,
"witch.sprite.json",
bevy::sprite::Anchor::Center,
);
// spawn the animated sprite
commands.spawn(AnimatedSpriteBundle {
animator: SpriteAnimator::from_anim(AnimHandle::from_index(1)),
spritesheet: sheet_handle,
..Default::default()
});
}
The AnimatedSpriteBundle
entity will remain invisible until the assets are finished loading
To run the example:
cargo run --example character
To see the complete example, see examples/character.rs.
The asset I used is a modified version of a free assset made by Legnops
https://legnops.itch.io/red-hood-character
Spritesheet::from_data()
AnimatedSpriteBundle
SpriteAnimator
SpriteAnimator
not rely on having loaded sheet when initializedSheet
type to Spritesheet