Crates.io | bevy_xml |
lib.rs | bevy_xml |
version | 0.2.0 |
source | src |
created_at | 2023-05-04 13:09:52.975622 |
updated_at | 2023-05-06 22:09:36.478878 |
description | An Sparrow SpriteSheet XML Parser for Bevy! |
homepage | |
repository | https://github.com/rayanmargham/bevy_xml |
max_upload_size | |
id | 856707 |
size | 23,033 |
This Crate is a plugin for Bevy to parse SpriteSheet XMLs! Most Useful in using assets from Adobe Animate.
Here below is some example code on how'd you use the crate:
use bevy::prelude::*;
use bevy_xml::*;
fn main()
{
app
.add_system(bevy_xml::tick_animations)
.run();
}
fn your_startup_system(mut texture_atlases: ResMut<Assets<TextureAtlas>>, asset_loader: Res<AssetServer>)
{
let bfs = texture_atlases.add(TextureAtlas::new_empty(asset_loader.load("images/bf.png"), Vec2::new(8192.0, 4096.0))); // handle
let Some(bf) = texture_atlases.get_mut(&bfs) else { return };
let xml = SpriteXMLBundle::new("assets/images/bf.xml".to_string(), &bfs, bf);
match xml {
Some(c) =>
{
c.add_anim_from_prefix("Epic Animation", false, 24); // anim name, is the animation looped?, fps
c.apply_offsets(); // applies inital offset
c.set_anim("Epic Animation", bf, true); // sets the current animation
// anim name^ sprite^ ^ set the current frame to zero?
commands.spawn(c);
},
None =>
{
error!("Failed to Parse XML!");
}
}
}
This crate now has an animation system, support for 3D sprites and much more!
I've never published a crate before so if there are any issues please give me feedback!