bevy_sprite_animation
bevy_sprite_animation copied to clipboard
Add support for animating based off of `TextureAtlas`s
Disclaimer: I'm rather new to bevy and this crate specifically, but I think this would be a useful feature for the crate.
I'm looking into some solutions myself, but I'd like to open it up to everyone else as well :).
My basic idea is to add a trait which can be implemented for Handle<Image>
and TextureAtlasSprite
pub trait AnimationMedium: Component {
type Frame;
fn num_frames(&self) -> usize;
fn current_index(&self) -> usize;
fn set_frame(&mut self, index: usize);
fn current_frame(&self) -> &Self::Frame;
}
And this trait would replace the query of Handle<Image>
in the animation system. Doing this method would require making the node types generic across this new trait as well.
I've done a little more work on this with a proof of concept of the trait here: https://github.com/rhaaaaawb/bevy_sprite_animation/tree/parsnips/spritesheet
I like this. I have wanted to do this change for a while but didn't know how. I was planning on just having it as a feature like Rapier 2d vs 3d but making it generic like that would be good. could you update your proof of concept to the V0.4 branch? and submit a pull request and ill have a deeper look to see if anything conflicts