bevy_spritesheet_animation is a Bevy plugin for easily animating 2D and 3D sprites.
[!TIP] This crate supports the latest Bevy 0.16. Please check the compatibility table to see which version of this crate to use with older Bevy versions.
[!NOTE] This crate is under active development. Please regularly check the CHANGELOG for recent changes.
Features
- Animate 2D sprites, 3D sprites, UI images and custom cursor icons! 🎉
- A single Bevy component to add to your entities to play animations.
- Tunable parameters: duration, repetitions, direction, easing.
- Composable animations from multiple clips.
- Events to react to animations ending or reaching specific points.
- A convenient API to select frames in spritesheets.
Quick start
- Add the SpritesheetAnimationPlugin to your app
- Use the AnimationLibrary resource to create new clips and animations
- Add SpritesheetAnimation components to your entities
use *;
use *;
Overview
Clips
A clip is a sequence of frames.
It is the most basic building block for creating animations. Simple animations may contain a single clip while more complex animations may contain a sequence of clips.
Parameters like duration, repetitions, direction and easing can be specified.
Use the AnimationLibrary resource to register a new clip.
The clip can then be referenced in any number of animations.
Animations
In its simplest form, an animation is composed of a single clip that loops endlessly.
However, you may compose more sophisticated animations by chaining multiple clips and tuning their parameters separately.
Use the AnimationLibrary resource to register a new animation.
The animation can then be referenced in any number of SpritesheetAnimation component.
Think of clips and animations as assets!
Clips and animations should be created once. You can then assign them to many entities.
❌ BAD
Do not create the same clip/animation for each entity that plays it.
👍 GOOD
Instead, create clips/animations once and then reference them when needed.
For instance, you can create all your animations in a setup system, give them unique names and then assign them to entities, immediately or at a later stage.
3D sprites
This crate also makes it easy to integrate 3D sprites into your games, which is not supported by Bevy out of the box.
Animating a 3D sprite is the same as animating 2D sprites: simply spawn a Sprite3d instead of Bevy's built-in Sprite and attach a SpritesheetAnimation component to the entity.
Custom cursor icons
You can animate custom cursor icons using this crate.
You need to enable the optional custom_cursor
feature.
[]
= { = "...", = ["...", "custom_cursor"] }
= { = "...", = ["custom_cursor"] }
When you spawn your cursor icon entity, add a SpritesheetAnimation
component as usual to play an animation.
More examples
For more examples, browse the examples/ directory.
Example | Description |
---|---|
basic | Shows how to create an animated sprite |
3d | Shows how to create 3D sprites |
progress | Shows how to control an animation |
composition | Shows how to create an animation with multiple clips |
parameters | Shows the effect of each animation parameter |
character | Shows how to create a controllable character with multiple animations |
events | Shows how to react to animations reaching points of interest with events |
headless | Shows how to run animations in a headless Bevy app without rendering |
stress | Stress test with thousands of animated sprites (either 2D or 3D) |
Compatibility
bevy | bevy_spritesheet_animation |
---|---|
0.16 | 3.0.0 |
0.15 | 2.0.0 |
0.14 | 0.2.0 |
0.13 | 0.1.0 |
Credits
- The character spritesheet used for the examples is CC0 from thekingphoenix