Skip to content

Commit 64f7460

Browse files
authored
Add animation system label (djeedai#23)
This lets you not have to run after every single system and instead just pass in the label.
1 parent 454bcd0 commit 64f7460

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
- Add `is_forward()` and `is_backward()` convenience helpers to `TweeningDirection`.
1111
- Add `Tween::set_direction()` and `Tween::with_direction()` which allow configuring the playback direction of a tween, allowing to play it backward from end to start.
1212
- Support dynamically changing an animation's speed with `Animator::set_speed`
13+
- Add `AnimationSystem` label to tweening tick systems
1314

1415
## [0.4.0] - 2022-04-16
1516

src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,9 @@ mod plugin;
158158
mod tweenable;
159159

160160
pub use lens::Lens;
161-
pub use plugin::{asset_animator_system, component_animator_system, TweeningPlugin};
161+
pub use plugin::{
162+
asset_animator_system, component_animator_system, AnimationSystem, TweeningPlugin,
163+
};
162164
pub use tweenable::{Delay, Sequence, Tracks, Tween, TweenCompleted, TweenState, Tweenable};
163165

164166
/// Type of looping for a tween animation.

src/plugin.rs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,29 @@ pub struct TweeningPlugin;
3333

3434
impl Plugin for TweeningPlugin {
3535
fn build(&self, app: &mut App) {
36-
app.add_event::<TweenCompleted>()
37-
.add_system(component_animator_system::<Transform>);
36+
app.add_event::<TweenCompleted>().add_system(
37+
component_animator_system::<Transform>.label(AnimationSystem::AnimationUpdate),
38+
);
3839

3940
#[cfg(feature = "bevy_ui")]
40-
app.add_system(component_animator_system::<Text>)
41-
.add_system(component_animator_system::<Style>);
41+
app.add_system(component_animator_system::<Text>.label(AnimationSystem::AnimationUpdate))
42+
.add_system(component_animator_system::<Style>.label(AnimationSystem::AnimationUpdate));
4243

4344
#[cfg(feature = "bevy_sprite")]
44-
app.add_system(component_animator_system::<Sprite>)
45-
.add_system(asset_animator_system::<ColorMaterial>);
45+
app.add_system(component_animator_system::<Sprite>.label(AnimationSystem::AnimationUpdate))
46+
.add_system(
47+
asset_animator_system::<ColorMaterial>.label(AnimationSystem::AnimationUpdate),
48+
);
4649
}
4750
}
4851

52+
/// Label enum for the systems relating to animations
53+
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash, SystemLabel)]
54+
pub enum AnimationSystem {
55+
/// Ticks animations
56+
AnimationUpdate,
57+
}
58+
4959
/// Animator system for components.
5060
///
5161
/// This system extracts all components of type `T` with an `Animator<T>` attached to the same entity,

0 commit comments

Comments
 (0)