Utilities for loading Aseprite files into a Bevy application.
Provides an AssetLoader struct which directly reads .aseprite files without an intermediate import step. The loader adds Resources generated by the files' data. Systems can invoke the loader's methods to start loading files, or query the loading state.
This library creates several types of resources:
- Texture data, which contains the file's images.
- TextureAtlas data, which contains mapping information for each sprite in a spritesheet.
- Animation data.
- Slice data.
- Tileset data (from files created in Aseprite v1.3 beta).
This library exposes AseLoaderDefaultPlugin with default settings. This plugin initializes all of the above resources as Asset types, adds Loader and AseAssetLoader resources, and adds an importer system function to process loaded ase data.
For a custom configuration, import the constituent parts and add them to AppBuilder directly. The Texture resource is required to be initialized. Other asset types are optional.
use bevy::prelude::*;
use bevy_ase::asset::AseAsset;
use bevy_ase::loader::{AseLoaderDefaultPlugin, Loader};
use std::path::Path;
// Initialize and run a bevy app with the default bevy_ase configuration.
fn main() {
App::build()
.add_plugins(DefaultPlugins)
.add_plugin(AseLoaderDefaultPlugin)
.add_system(load_sprites.system());
}
// Get an aseprite asset and send it to the loader.
pub fn load_sprites(asset_server: Res<AssetServer>, mut loader: ResMut<Loader>) {
let h: Handle<AseAsset> = asset_server.load(Path::new("sprites/hello.aseprite"));
loader.add(h.clone());
}
See the documentation for lib.rs for more information.
Forked from https://github.com/alpine-alpaca/bevy_proto_aseprite.
cargo run --example animated --features="benimator"
-
Improve error handling.
-
Atlas creation fails if there are too many / too big sprites.
-
Hot reloading. This requires dynamic atlas reconstruction.