bevy_map_animation
Sprite sheet animations for the bevy_map_editor ecosystem.
Part of bevy_map_editor.
Features
- Define sprite sheets with frame dimensions
- Multiple named animations per sheet
- Loop modes: Loop, Once, PingPong
- Frame-based timing
- Automatic sprite rect updates
- Animation Triggers: One-shot events at specific times (sounds, VFX, game events)
- Animation Windows: Duration-based events with Begin/Tick/End phases (hitboxes, combo windows)
- Custom Event Types: Type-safe extensible trigger/window system with Bevy Observers
Types
| Type | Description |
|---|---|
SpriteData |
Sprite sheet definition with animations |
AnimationDef |
Single animation (frames, timing, loop mode) |
AnimatedSprite |
Component for playing animations |
AnimationTrigger |
One-shot trigger definition (time + payload) |
AnimationWindow |
Duration-based window definition (start/end + payload) |
LoopMode |
Loop, Once, or PingPong |
WindowTracker |
Component to enable window event tracking |
Events
| Event | Description |
|---|---|
AnimationTriggerEvent |
Fired when a trigger fires (generic) |
AnimationWindowEvent |
Fired for window phase changes (Begin/Tick/End) |
AnimationSoundEvent |
Convenience event for sound payloads |
AnimationParticleEvent |
Convenience event for particle/VFX payloads |
AnimationCustomEvent |
Convenience event for custom payloads |
Usage
Defining Animations (Code)
use ;
let mut sprite = new;
sprite.add_animation;
sprite.add_animation;
Adding Triggers and Windows
use ;
let mut attack_anim = new;
// One-shot trigger at 240ms - play impact sound
attack_anim.add_trigger;
// Duration-based window from 160-320ms - hitbox active
attack_anim.add_window;
Handling Animation Events
use *;
use ;
Custom Type-Safe Triggers
Define custom trigger types for type-safe event handling with Bevy Observers:
use *;
use ;
use Value;
use HashMap;
// Register the custom trigger type
app.;
// Handle with Bevy Observer
Playing Animations
use *;
use *;
Enabling Window Events
Add WindowTracker component to entities that need window event tracking:
commands.spawn;
Auto-Loading from Maps
Use AnimatedSpriteHandle for automatic loading:
use AnimatedSpriteHandle;
commands.spawn;
Plugin
Add SpriteAnimationPlugin for automatic animation updates:
use *;
app.add_plugins;
Note: MapRuntimePlugin includes this automatically.
License
MIT OR Apache-2.0