Skip to content

Commit

Permalink
Revert "Support running an animation N times (#19)"
Browse files Browse the repository at this point in the history
This reverts commit 6a87157.
  • Loading branch information
djeedai committed Aug 4, 2022
1 parent 3637916 commit d0f5168
Show file tree
Hide file tree
Showing 11 changed files with 252 additions and 292 deletions.
20 changes: 6 additions & 14 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- Added `is_forward()` and `is_backward()` convenience helpers to `TweeningDirection`.
- Added `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.
- Added support for dynamically changing an animation's speed with `Animator::set_speed`.
- Added `AnimationSystem` label to tweening tick systems.
- Added `BoxedTweenable` type to make working with `Box<dyn Tweenable + ...>` easier.
- Added `RepeatCount` and `RepeatStrategy` for more granular control over animation looping.
- Added `with_repeat_count()` and `with_repeat_strategy()` builder methods to `Tween<T>`.
- Add `is_forward()` and `is_backward()` convenience helpers to `TweeningDirection`.
- 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.
- Support dynamically changing an animation's speed with `Animator::set_speed`
- Add `AnimationSystem` label to tweening tick systems
- A `BoxedTweenable` type to make working with `Box<dyn Tweenable + ...>` easier

### Changed

- Double boxing in `Sequence` and `Tracks` was fixed. As a result, any custom tweenables.
- Double boxing in `Sequence` and `Tracks` was fixed. As a result, any custom tweenables
should implement `From` for `BoxedTweenable` to make those APIs easier to use.
- Removed the `tweening_type` parameter from the signature of `Tween<T>::new()`; use `with_repeat_count()` and `with_repeat_strategy()` instead.

### Removed

- Removed `Tweenable::is_looping()`, which was not implemented for most tweenables.
- Removed `TweeningType` in favor of `RepeatCount` and `RepeatStrategy`.

## [0.4.0] - 2022-04-16

Expand Down
5 changes: 2 additions & 3 deletions examples/colormaterial_color.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,13 @@ fn setup(

let tween = Tween::new(
*ease_function,
TweeningType::PingPong,
Duration::from_secs(1),
ColorMaterialColorLens {
start: Color::RED,
end: Color::BLUE,
},
)
.with_repeat_count(RepeatCount::Infinite)
.with_repeat_strategy(RepeatStrategy::MirroredRepeat);
);

commands
.spawn_bundle(MaterialMesh2dBundle {
Expand Down
1 change: 1 addition & 0 deletions examples/menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
start_time_ms += 500;
let tween_scale = Tween::new(
EaseFunction::BounceOut,
TweeningType::Once,
Duration::from_secs(2),
TransformScaleLens {
start: Vec3::splat(0.01),
Expand Down
43 changes: 16 additions & 27 deletions examples/sequence.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
use std::time::Duration;

use bevy::prelude::*;

use bevy_tweening::{lens::*, *};
use std::time::Duration;

fn main() {
App::default()
Expand Down Expand Up @@ -109,31 +107,19 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
Vec3::new(margin, screen_y - margin, 0.),
Vec3::new(margin, margin, 0.),
];
// Build a sequence from an iterator over a Tweenable (here, a
// Tracks<Transform>)
// Build a sequence from an iterator over a Tweenable (here, a Tween<Transform>)
let seq = Sequence::new(dests.windows(2).enumerate().map(|(index, pair)| {
Tracks::new([
Tween::new(
EaseFunction::QuadraticInOut,
Duration::from_millis(250),
TransformRotateZLens {
start: 0.,
end: 180_f32.to_radians(),
},
)
.with_repeat_count(RepeatCount::Finite(4))
.with_repeat_strategy(RepeatStrategy::MirroredRepeat),
Tween::new(
EaseFunction::QuadraticInOut,
Duration::from_secs(1),
TransformPositionLens {
start: pair[0] - center,
end: pair[1] - center,
},
)
// Get an event after each segment
.with_completed_event(index as u64),
])
Tween::new(
EaseFunction::QuadraticInOut,
TweeningType::Once,
Duration::from_secs(1),
TransformPositionLens {
start: pair[0] - center,
end: pair[1] - center,
},
)
// Get an event after each segment
.with_completed_event(index as u64)
}));

commands
Expand All @@ -152,6 +138,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
// scaling size at the same time.
let tween_move = Tween::new(
EaseFunction::QuadraticInOut,
TweeningType::Once,
Duration::from_secs(1),
TransformPositionLens {
start: Vec3::new(-200., 100., 0.),
Expand All @@ -161,6 +148,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
.with_completed_event(99); // Get an event once move completed
let tween_rotate = Tween::new(
EaseFunction::QuadraticInOut,
TweeningType::Once,
Duration::from_secs(1),
TransformRotationLens {
start: Quat::IDENTITY,
Expand All @@ -169,6 +157,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
);
let tween_scale = Tween::new(
EaseFunction::QuadraticInOut,
TweeningType::Once,
Duration::from_secs(1),
TransformScaleLens {
start: Vec3::ONE,
Expand Down
5 changes: 2 additions & 3 deletions examples/sprite_color.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,13 @@ fn setup(mut commands: Commands) {
] {
let tween = Tween::new(
*ease_function,
TweeningType::PingPong,
std::time::Duration::from_secs(1),
SpriteColorLens {
start: Color::RED,
end: Color::BLUE,
},
)
.with_repeat_count(RepeatCount::Infinite)
.with_repeat_strategy(RepeatStrategy::MirroredRepeat);
);

commands
.spawn_bundle(SpriteBundle {
Expand Down
5 changes: 2 additions & 3 deletions examples/text_color.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,14 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
] {
let tween = Tween::new(
*ease_function,
TweeningType::PingPong,
std::time::Duration::from_secs(1),
TextColorLens {
start: Color::RED,
end: Color::BLUE,
section: 0,
},
)
.with_repeat_count(RepeatCount::Infinite)
.with_repeat_strategy(RepeatStrategy::MirroredRepeat);
);

commands
.spawn_bundle(TextBundle {
Expand Down
5 changes: 2 additions & 3 deletions examples/transform_rotation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,13 @@ fn setup(mut commands: Commands) {
] {
let tween = Tween::new(
*ease_function,
TweeningType::PingPong,
std::time::Duration::from_secs(1),
TransformRotationLens {
start: Quat::IDENTITY,
end: Quat::from_axis_angle(Vec3::Z, std::f32::consts::PI / 2.),
},
)
.with_repeat_count(RepeatCount::Infinite)
.with_repeat_strategy(RepeatStrategy::MirroredRepeat);
);

commands
.spawn_bundle((
Expand Down
5 changes: 2 additions & 3 deletions examples/transform_translation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,13 @@ fn setup(mut commands: Commands) {
] {
let tween = Tween::new(
*ease_function,
TweeningType::PingPong,
std::time::Duration::from_secs(1),
TransformPositionLens {
start: Vec3::new(x, screen_y, 0.),
end: Vec3::new(x, -screen_y, 0.),
},
)
.with_repeat_count(RepeatCount::Infinite)
.with_repeat_strategy(RepeatStrategy::MirroredRepeat);
);

commands
.spawn_bundle(SpriteBundle {
Expand Down
5 changes: 2 additions & 3 deletions examples/ui_position.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ fn setup(mut commands: Commands) {
] {
let tween = Tween::new(
*ease_function,
TweeningType::PingPong,
std::time::Duration::from_secs(1),
UiPositionLens {
start: Rect {
Expand All @@ -91,9 +92,7 @@ fn setup(mut commands: Commands) {
bottom: Val::Auto,
},
},
)
.with_repeat_count(RepeatCount::Infinite)
.with_repeat_strategy(RepeatStrategy::MirroredRepeat);
);

commands
.spawn_bundle(NodeBundle {
Expand Down
Loading

0 comments on commit d0f5168

Please sign in to comment.