From 30bc490b03f2c2a81050e99d2bf39fd81e42cd46 Mon Sep 17 00:00:00 2001 From: Jerome Humbert <djeedai@gmail.com> Date: Mon, 14 Nov 2022 21:39:51 +0000 Subject: [PATCH] Upgrade to Bevy 0.9 (#76) --- CHANGELOG.md | 1 + Cargo.toml | 6 ++-- README.md | 60 ++++++++++++++++++++------------------ benchmarks/Cargo.toml | 4 +-- benchmarks/benches/lens.rs | 6 ++-- run_examples.bat | 15 ++++++++++ src/lens.rs | 48 +++++++++++++++--------------- src/lib.rs | 12 ++++---- src/plugin.rs | 16 ++++------ src/tweenable.rs | 7 +++-- 10 files changed, 95 insertions(+), 80 deletions(-) create mode 100644 run_examples.bat diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d6dd16..6f7c8ef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- Compatible with Bevy 0.9 - Removed the `tweening_type` parameter from the signature of `Tween<T>::new()`; use `with_repeat_count()` and `with_repeat_strategy()` instead. - Animators now always have a tween (instead of it being optional). This means the default animator implementation was removed. - `Delay::new()` now panics if the `duration` is zero. This prevents creating no-op `Delay` objects, and avoids an internal edge case producing wrong results. diff --git a/Cargo.toml b/Cargo.toml index af36c3a..b8cb41e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bevy_tweening" -version = "0.5.1" +version = "0.6.0" authors = ["François Mockers <mockersf@gmail.com>", "Jerome Humbert <djeedai@gmail.com>"] edition = "2021" description = "Tweening animation plugin for the Bevy game engine" @@ -25,10 +25,10 @@ bevy_text = ["bevy/bevy_text", "bevy/bevy_render"] [dependencies] interpolation = "0.2" -bevy = { version = "0.8", default-features = false } +bevy = { version = "0.9", default-features = false } [dev-dependencies] -bevy-inspector-egui = "0.12" +bevy-inspector-egui = "0.14" [[example]] name = "menu" diff --git a/README.md b/README.md index 206cf3a..e8a3eaf 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ [](https://crates.io/crates/bevy_tweening) [](https://github.com/djeedai/bevy_tweening/actions/workflows/ci.yaml) [](https://coveralls.io/github/djeedai/bevy_tweening?branch=main) -[](https://github.com/bevyengine/bevy/blob/main/docs/plugins_guidelines.md#main-branch-tracking) +[](https://github.com/bevyengine/bevy/blob/main/docs/plugins_guidelines.md#main-branch-tracking) Tweening animation plugin for the Bevy game engine. @@ -56,8 +56,6 @@ Animate the transform position of an entity by creating a `Tween` animation for let tween = Tween::new( // Use a quadratic easing on both endpoints. EaseFunction::QuadraticInOut, - // Loop animation back and forth. - TweeningType::PingPong, // Animation time (one way only; for ping-pong it takes 2 seconds // to come back to start). Duration::from_secs(1), @@ -68,21 +66,25 @@ let tween = Tween::new( start: Vec3::ZERO, end: Vec3::new(1., 2., -4.), }, -); +) +// Repeat twice (one per way) +.with_repeat_count(RepeatCount::Finite(2)) +// After each iteration, reverse direction (ping-pong) +.with_repeat_strategy(RepeatStrategy::MirroredRepeat); -commands +commands.spawn(( // Spawn a Sprite entity to animate the position of. - .spawn_bundle(SpriteBundle { + SpriteBundle { sprite: Sprite { color: Color::RED, custom_size: Some(Vec2::new(size, size)), ..default() }, ..default() - }) + }, // Add an Animator component to control and execute the animation. - .insert(Animator::new(tween)); -} + Animator::new(tween), +)); ``` ### Chaining animations @@ -105,7 +107,7 @@ let seq = tween1.then(tween2); ## Predefined Lenses -A small number of predefined lenses are available for the most common use cases, which also serve as examples. Users are encouraged to write their own lens to tailor the animation to their use case. +A small number of predefined lenses are available for the most common use cases, which also serve as examples. **Users are encouraged to write their own lens to tailor the animation to their use case.** The naming scheme for predefined lenses is `"<TargetName><FieldName>Lens"`, where `<TargetName>` is the name of the target Bevy component or asset type which is queried by the internal animation system to be modified, and `<FieldName>` is the field which is mutated in place by the lens. All predefined lenses modify a single field. Custom lenses can be written which modify multiple fields at once. @@ -113,16 +115,16 @@ The naming scheme for predefined lenses is `"<TargetName><FieldName>Lens"`, wher | Target Component | Animated Field | Lens | Feature | |---|---|---|---| -| [`Transform`](https://docs.rs/bevy/0.8.0/bevy/transform/components/struct.Transform.html) | [`translation`](https://docs.rs/bevy/0.8.0/bevy/transform/components/struct.Transform.html#structfield.translation) | [`TransformPositionLens`](https://docs.rs/bevy_tweening/latest/bevy_tweening/struct.TransformPositionLens.html) | | -| | [`rotation`](https://docs.rs/bevy/0.8.0/bevy/transform/components/struct.Transform.html#structfield.rotation) (`Quat`)¹ | [`TransformRotationLens`](https://docs.rs/bevy_tweening/latest/bevy_tweening/struct.TransformRotationLens.html) | | -| | [`rotation`](https://docs.rs/bevy/0.8.0/bevy/transform/components/struct.Transform.html#structfield.rotation) (angle)² | [`TransformRotateXLens`](https://docs.rs/bevy_tweening/latest/bevy_tweening/struct.TransformRotateXLens.html) | | -| | [`rotation`](https://docs.rs/bevy/0.8.0/bevy/transform/components/struct.Transform.html#structfield.rotation) (angle)² | [`TransformRotateYLens`](https://docs.rs/bevy_tweening/latest/bevy_tweening/struct.TransformRotateYLens.html) | | -| | [`rotation`](https://docs.rs/bevy/0.8.0/bevy/transform/components/struct.Transform.html#structfield.rotation) (angle)² | [`TransformRotateZLens`](https://docs.rs/bevy_tweening/latest/bevy_tweening/struct.TransformRotateZLens.html) | | -| | [`rotation`](https://docs.rs/bevy/0.8.0/bevy/transform/components/struct.Transform.html#structfield.rotation) (angle)² | [`TransformRotateAxisLens`](https://docs.rs/bevy_tweening/latest/bevy_tweening/struct.TransformRotateAxisLens.html) | | -| | [`scale`](https://docs.rs/bevy/0.8.0/bevy/transform/components/struct.Transform.html#structfield.scale) | [`TransformScaleLens`](https://docs.rs/bevy_tweening/latest/bevy_tweening/struct.TransformScaleLens.html) | | -| [`Sprite`](https://docs.rs/bevy/0.8.0/bevy/sprite/struct.Sprite.html) | [`color`](https://docs.rs/bevy/0.8.0/bevy/sprite/struct.Sprite.html#structfield.color) | [`SpriteColorLens`](https://docs.rs/bevy_tweening/latest/bevy_tweening/struct.SpriteColorLens.html) | `bevy_sprite` | -| [`Style`](https://docs.rs/bevy/0.8.0/bevy/ui/struct.Style.html) | [`position`](https://docs.rs/bevy/0.8.0/bevy/ui/struct.Style.html#structfield.position) | [`UiPositionLens`](https://docs.rs/bevy_tweening/latest/bevy_tweening/struct.UiPositionLens.html) | `bevy_ui` | -| [`Text`](https://docs.rs/bevy/0.8.0/bevy/text/struct.Text.html) | [`TextStyle::color`](https://docs.rs/bevy/0.8.0/bevy/text/struct.TextStyle.html#structfield.color) | [`TextColorLens`](https://docs.rs/bevy_tweening/latest/bevy_tweening/struct.TextColorLens.html) | `bevy_text` | +| [`Transform`](https://docs.rs/bevy/0.9.0/bevy/transform/components/struct.Transform.html) | [`translation`](https://docs.rs/bevy/0.9.0/bevy/transform/components/struct.Transform.html#structfield.translation) | [`TransformPositionLens`](https://docs.rs/bevy_tweening/latest/bevy_tweening/struct.TransformPositionLens.html) | | +| | [`rotation`](https://docs.rs/bevy/0.9.0/bevy/transform/components/struct.Transform.html#structfield.rotation) (`Quat`)¹ | [`TransformRotationLens`](https://docs.rs/bevy_tweening/latest/bevy_tweening/struct.TransformRotationLens.html) | | +| | [`rotation`](https://docs.rs/bevy/0.9.0/bevy/transform/components/struct.Transform.html#structfield.rotation) (angle)² | [`TransformRotateXLens`](https://docs.rs/bevy_tweening/latest/bevy_tweening/struct.TransformRotateXLens.html) | | +| | [`rotation`](https://docs.rs/bevy/0.9.0/bevy/transform/components/struct.Transform.html#structfield.rotation) (angle)² | [`TransformRotateYLens`](https://docs.rs/bevy_tweening/latest/bevy_tweening/struct.TransformRotateYLens.html) | | +| | [`rotation`](https://docs.rs/bevy/0.9.0/bevy/transform/components/struct.Transform.html#structfield.rotation) (angle)² | [`TransformRotateZLens`](https://docs.rs/bevy_tweening/latest/bevy_tweening/struct.TransformRotateZLens.html) | | +| | [`rotation`](https://docs.rs/bevy/0.9.0/bevy/transform/components/struct.Transform.html#structfield.rotation) (angle)² | [`TransformRotateAxisLens`](https://docs.rs/bevy_tweening/latest/bevy_tweening/struct.TransformRotateAxisLens.html) | | +| | [`scale`](https://docs.rs/bevy/0.9.0/bevy/transform/components/struct.Transform.html#structfield.scale) | [`TransformScaleLens`](https://docs.rs/bevy_tweening/latest/bevy_tweening/struct.TransformScaleLens.html) | | +| [`Sprite`](https://docs.rs/bevy/0.9.0/bevy/sprite/struct.Sprite.html) | [`color`](https://docs.rs/bevy/0.9.0/bevy/sprite/struct.Sprite.html#structfield.color) | [`SpriteColorLens`](https://docs.rs/bevy_tweening/latest/bevy_tweening/struct.SpriteColorLens.html) | `bevy_sprite` | +| [`Style`](https://docs.rs/bevy/0.9.0/bevy/ui/struct.Style.html) | [`position`](https://docs.rs/bevy/0.9.0/bevy/ui/struct.Style.html#structfield.position) | [`UiPositionLens`](https://docs.rs/bevy_tweening/latest/bevy_tweening/struct.UiPositionLens.html) | `bevy_ui` | +| [`Text`](https://docs.rs/bevy/0.9.0/bevy/text/struct.Text.html) | [`TextStyle::color`](https://docs.rs/bevy/0.9.0/bevy/text/struct.TextStyle.html#structfield.color) | [`TextColorLens`](https://docs.rs/bevy_tweening/latest/bevy_tweening/struct.TextColorLens.html) | `bevy_text` | ¹ Shortest-path interpolation between two rotations, using `Quat::slerp()`. @@ -136,7 +138,7 @@ Asset animation always requires the `bevy_asset` feature. | Target Asset | Animated Field | Lens | Feature | |---|---|---|---| -| [`ColorMaterial`](https://docs.rs/bevy/0.8.0/bevy/sprite/struct.ColorMaterial.html) | [`color`](https://docs.rs/bevy/0.8.0/bevy/sprite/struct.ColorMaterial.html#structfield.color) | [`ColorMaterialColorLens`](https://docs.rs/bevy_tweening/latest/bevy_tweening/struct.ColorMaterialColorLens.html) | `bevy_asset` + `bevy_sprite` | +| [`ColorMaterial`](https://docs.rs/bevy/0.9.0/bevy/sprite/struct.ColorMaterial.html) | [`color`](https://docs.rs/bevy/0.9.0/bevy/sprite/struct.ColorMaterial.html#structfield.color) | [`ColorMaterialColorLens`](https://docs.rs/bevy_tweening/latest/bevy_tweening/struct.ColorMaterialColorLens.html) | `bevy_asset` + `bevy_sprite` | ## Custom lens @@ -194,7 +196,7 @@ The process is similar to custom components, creating a custom lens for the cust ## Examples -See the [`examples/`](https://github.com/djeedai/bevy_tweening/tree/8473330a707d80af7cdff2abd2de4a3cb72a87ad/examples) folder. +See the [`examples/`](https://github.com/djeedai/bevy_tweening/tree/fcc8910568a00b892e66586a7359ea3552c840a2/examples) folder. ### [`menu`](examples/menu.rs) @@ -202,7 +204,7 @@ See the [`examples/`](https://github.com/djeedai/bevy_tweening/tree/8473330a707d cargo run --example menu --features="bevy/bevy_winit" ``` - + ### [`sprite_color`](examples/sprite_color.rs) @@ -210,7 +212,7 @@ cargo run --example menu --features="bevy/bevy_winit" cargo run --example sprite_color --features="bevy/bevy_winit" ``` - + ### [`transform_rotation`](examples/transform_rotation.rs) @@ -218,7 +220,7 @@ cargo run --example sprite_color --features="bevy/bevy_winit" cargo run --example transform_rotation --features="bevy/bevy_winit" ``` - + ### [`transform_translation`](examples/transform_translation.rs) @@ -226,7 +228,7 @@ cargo run --example transform_rotation --features="bevy/bevy_winit" cargo run --example transform_translation --features="bevy/bevy_winit" ``` - + ### [`colormaterial_color`](examples/colormaterial_color.rs) @@ -234,7 +236,7 @@ cargo run --example transform_translation --features="bevy/bevy_winit" cargo run --example colormaterial_color --features="bevy/bevy_winit" ``` - + ### [`ui_position`](examples/ui_position.rs) @@ -242,7 +244,7 @@ cargo run --example colormaterial_color --features="bevy/bevy_winit" cargo run --example ui_position --features="bevy/bevy_winit" ``` - + ### [`sequence`](examples/sequence.rs) @@ -250,7 +252,7 @@ cargo run --example ui_position --features="bevy/bevy_winit" cargo run --example sequence --features="bevy/bevy_winit" ``` - + ## Ease Functions diff --git a/benchmarks/Cargo.toml b/benchmarks/Cargo.toml index be7e057..3cc3fb9 100644 --- a/benchmarks/Cargo.toml +++ b/benchmarks/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bevy_tweening_bench" -version = "0.2.0" +version = "0.3.0" authors = ["Jerome Humbert <djeedai@gmail.com>"] edition = "2021" description = "Tweening plugin for Bevy -- Benchmarks" @@ -18,7 +18,7 @@ criterion = { version = "0.3", features = ["html_reports"] } bevy_tweening = { path = "../" } [dependencies.bevy] -version = "0.8.0" +version = "0.9.0" default-features = false features = [ "render" ] diff --git a/benchmarks/benches/lens.rs b/benchmarks/benches/lens.rs index 8c87acb..d59d375 100644 --- a/benchmarks/benches/lens.rs +++ b/benchmarks/benches/lens.rs @@ -33,7 +33,7 @@ fn transform_position_lens(c: &mut Criterion) { start: Vec3::ZERO, end: Vec3::ONE, }; - let mut transform = Transform::identity(); + let mut transform = Transform::IDENTITY; c.bench_function("TransformPositionLens", |b| { b.iter(|| lens.lerp(&mut transform, black_box(0.3))) }); @@ -44,7 +44,7 @@ fn transform_rotation_lens(c: &mut Criterion) { start: Quat::IDENTITY, end: Quat::from_rotation_x(72.0_f32.to_radians()), }; - let mut transform = Transform::identity(); + let mut transform = Transform::IDENTITY; c.bench_function("TransformRotationLens", |b| { b.iter(|| lens.lerp(&mut transform, black_box(0.3))) }); @@ -55,7 +55,7 @@ fn transform_scale_lens(c: &mut Criterion) { start: Vec3::ONE, end: Vec3::new(1.5, 2.0, 3.0), }; - let mut transform = Transform::identity(); + let mut transform = Transform::IDENTITY; c.bench_function("TransformScaleLens", |b| { b.iter(|| lens.lerp(&mut transform, black_box(0.3))) }); diff --git a/run_examples.bat b/run_examples.bat new file mode 100644 index 0000000..83444a8 --- /dev/null +++ b/run_examples.bat @@ -0,0 +1,15 @@ +@echo on +echo Run all examples +REM Default +cargo r --example menu --no-default-features --features="bevy/bevy_winit" +cargo r --example transform_translation --no-default-features --features="bevy/bevy_winit" +cargo r --example transform_rotation --no-default-features --features="bevy/bevy_winit" +cargo r --example sequence --no-default-features --features="bevy/bevy_winit" +REM bevy_sprite +cargo r --example sprite_color --no-default-features --features="bevy_sprite bevy/bevy_winit" +REM bevy_ui +cargo r --example ui_position --no-default-features --features="bevy_ui bevy/bevy_winit" +REM bevy_text +cargo r --example text_color --no-default-features --features="bevy_text bevy/bevy_winit" +REM bevy_sprite + bevy_asset +cargo r --example colormaterial_color --no-default-features --features="bevy_asset bevy_sprite bevy/bevy_winit" \ No newline at end of file diff --git a/src/lens.rs b/src/lens.rs index 016b03f..f6c1514 100644 --- a/src/lens.rs +++ b/src/lens.rs @@ -31,9 +31,9 @@ //! - [`TransformRotateZLens`] //! - [`TransformRotateAxisLens`] //! -//! [`rotation`]: https://docs.rs/bevy/0.8.0/bevy/transform/components/struct.Transform.html#structfield.rotation -//! [`Transform`]: https://docs.rs/bevy/0.8.0/bevy/transform/components/struct.Transform.html -//! [`Quat::slerp()`]: https://docs.rs/bevy/0.8.0/bevy/math/struct.Quat.html#method.slerp +//! [`rotation`]: https://docs.rs/bevy/0.9.0/bevy/transform/components/struct.Transform.html#structfield.rotation +//! [`Transform`]: https://docs.rs/bevy/0.9.0/bevy/transform/components/struct.Transform.html +//! [`Quat::slerp()`]: https://docs.rs/bevy/0.9.0/bevy/math/struct.Quat.html#method.slerp use bevy::prelude::*; @@ -77,8 +77,8 @@ pub trait Lens<T> { /// A lens to manipulate the [`color`] field of a section of a [`Text`] /// component. /// -/// [`color`]: https://docs.rs/bevy/0.8.0/bevy/text/struct.TextStyle.html#structfield.color -/// [`Text`]: https://docs.rs/bevy/0.8.0/bevy/text/struct.Text.html +/// [`color`]: https://docs.rs/bevy/0.9.0/bevy/text/struct.TextStyle.html#structfield.color +/// [`Text`]: https://docs.rs/bevy/0.9.0/bevy/text/struct.Text.html #[cfg(feature = "bevy_text")] #[derive(Debug, Copy, Clone, PartialEq)] pub struct TextColorLens { @@ -104,8 +104,8 @@ impl Lens<Text> for TextColorLens { /// A lens to manipulate the [`translation`] field of a [`Transform`] component. /// -/// [`translation`]: https://docs.rs/bevy/0.8.0/bevy/transform/components/struct.Transform.html#structfield.translation -/// [`Transform`]: https://docs.rs/bevy/0.8.0/bevy/transform/components/struct.Transform.html +/// [`translation`]: https://docs.rs/bevy/0.9.0/bevy/transform/components/struct.Transform.html#structfield.translation +/// [`Transform`]: https://docs.rs/bevy/0.9.0/bevy/transform/components/struct.Transform.html #[derive(Debug, Copy, Clone, PartialEq)] pub struct TransformPositionLens { /// Start value of the translation. @@ -134,9 +134,9 @@ impl Lens<Transform> for TransformPositionLens { /// See the [top-level `lens` module documentation] for a comparison of rotation /// lenses. /// -/// [`rotation`]: https://docs.rs/bevy/0.8.0/bevy/transform/components/struct.Transform.html#structfield.rotation -/// [`Transform`]: https://docs.rs/bevy/0.8.0/bevy/transform/components/struct.Transform.html -/// [`Quat::slerp()`]: https://docs.rs/bevy/0.8.0/bevy/math/struct.Quat.html#method.slerp +/// [`rotation`]: https://docs.rs/bevy/0.9.0/bevy/transform/components/struct.Transform.html#structfield.rotation +/// [`Transform`]: https://docs.rs/bevy/0.9.0/bevy/transform/components/struct.Transform.html +/// [`Quat::slerp()`]: https://docs.rs/bevy/0.9.0/bevy/math/struct.Quat.html#method.slerp /// [top-level `lens` module documentation]: crate::lens #[derive(Debug, Copy, Clone, PartialEq)] pub struct TransformRotationLens { @@ -162,7 +162,7 @@ impl Lens<Transform> for TransformRotationLens { /// See the [top-level `lens` module documentation] for a comparison of rotation /// lenses. /// -/// [`Transform`]: https://docs.rs/bevy/0.8.0/bevy/transform/components/struct.Transform.html +/// [`Transform`]: https://docs.rs/bevy/0.9.0/bevy/transform/components/struct.Transform.html /// [top-level `lens` module documentation]: crate::lens #[derive(Debug, Copy, Clone, PartialEq)] pub struct TransformRotateXLens { @@ -189,7 +189,7 @@ impl Lens<Transform> for TransformRotateXLens { /// See the [top-level `lens` module documentation] for a comparison of rotation /// lenses. /// -/// [`Transform`]: https://docs.rs/bevy/0.8.0/bevy/transform/components/struct.Transform.html +/// [`Transform`]: https://docs.rs/bevy/0.9.0/bevy/transform/components/struct.Transform.html /// [top-level `lens` module documentation]: crate::lens #[derive(Debug, Copy, Clone, PartialEq)] pub struct TransformRotateYLens { @@ -216,7 +216,7 @@ impl Lens<Transform> for TransformRotateYLens { /// See the [top-level `lens` module documentation] for a comparison of rotation /// lenses. /// -/// [`Transform`]: https://docs.rs/bevy/0.8.0/bevy/transform/components/struct.Transform.html +/// [`Transform`]: https://docs.rs/bevy/0.9.0/bevy/transform/components/struct.Transform.html /// [top-level `lens` module documentation]: crate::lens #[derive(Debug, Copy, Clone, PartialEq)] pub struct TransformRotateZLens { @@ -247,7 +247,7 @@ impl Lens<Transform> for TransformRotateZLens { /// /// This method panics if the `axis` vector is not normalized. /// -/// [`Transform`]: https://docs.rs/bevy/0.8.0/bevy/transform/components/struct.Transform.html +/// [`Transform`]: https://docs.rs/bevy/0.9.0/bevy/transform/components/struct.Transform.html /// [top-level `lens` module documentation]: crate::lens #[derive(Debug, Copy, Clone, PartialEq)] pub struct TransformRotateAxisLens { @@ -268,8 +268,8 @@ impl Lens<Transform> for TransformRotateAxisLens { /// A lens to manipulate the [`scale`] field of a [`Transform`] component. /// -/// [`scale`]: https://docs.rs/bevy/0.8.0/bevy/transform/components/struct.Transform.html#structfield.scale -/// [`Transform`]: https://docs.rs/bevy/0.8.0/bevy/transform/components/struct.Transform.html +/// [`scale`]: https://docs.rs/bevy/0.9.0/bevy/transform/components/struct.Transform.html#structfield.scale +/// [`Transform`]: https://docs.rs/bevy/0.9.0/bevy/transform/components/struct.Transform.html #[derive(Debug, Copy, Clone, PartialEq)] pub struct TransformScaleLens { /// Start value of the scale. @@ -287,15 +287,15 @@ impl Lens<Transform> for TransformScaleLens { /// A lens to manipulate the [`position`] field of a UI [`Style`] component. /// -/// [`position`]: https://docs.rs/bevy/0.8.0/bevy/ui/struct.Style.html#structfield.position -/// [`Style`]: https://docs.rs/bevy/0.8.0/bevy/ui/struct.Style.html +/// [`position`]: https://docs.rs/bevy/0.9.0/bevy/ui/struct.Style.html#structfield.position +/// [`Style`]: https://docs.rs/bevy/0.9.0/bevy/ui/struct.Style.html #[cfg(feature = "bevy_ui")] #[derive(Debug, Copy, Clone, PartialEq)] pub struct UiPositionLens { /// Start position. - pub start: UiRect<Val>, + pub start: UiRect, /// End position. - pub end: UiRect<Val>, + pub end: UiRect, } #[cfg(feature = "bevy_ui")] @@ -323,8 +323,8 @@ impl Lens<Style> for UiPositionLens { /// A lens to manipulate the [`color`] field of a [`ColorMaterial`] asset. /// -/// [`color`]: https://docs.rs/bevy/0.8.0/bevy/sprite/struct.ColorMaterial.html#structfield.color -/// [`ColorMaterial`]: https://docs.rs/bevy/0.8.0/bevy/sprite/struct.ColorMaterial.html +/// [`color`]: https://docs.rs/bevy/0.9.0/bevy/sprite/struct.ColorMaterial.html#structfield.color +/// [`ColorMaterial`]: https://docs.rs/bevy/0.9.0/bevy/sprite/struct.ColorMaterial.html #[cfg(feature = "bevy_sprite")] #[derive(Debug, Copy, Clone, PartialEq)] pub struct ColorMaterialColorLens { @@ -348,8 +348,8 @@ impl Lens<ColorMaterial> for ColorMaterialColorLens { /// A lens to manipulate the [`color`] field of a [`Sprite`] asset. /// -/// [`color`]: https://docs.rs/bevy/0.8.0/bevy/sprite/struct.Sprite.html#structfield.color -/// [`Sprite`]: https://docs.rs/bevy/0.8.0/bevy/sprite/struct.Sprite.html +/// [`color`]: https://docs.rs/bevy/0.9.0/bevy/sprite/struct.Sprite.html#structfield.color +/// [`Sprite`]: https://docs.rs/bevy/0.9.0/bevy/sprite/struct.Sprite.html #[cfg(feature = "bevy_sprite")] #[derive(Debug, Copy, Clone, PartialEq)] pub struct SpriteColorLens { diff --git a/src/lib.rs b/src/lib.rs index f139914..1c1fc6a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -144,12 +144,12 @@ //! lens can also be created by implementing the trait, allowing to animate //! virtually any field of any Bevy component or asset. //! -//! [`Transform::translation`]: https://docs.rs/bevy/0.8.0/bevy/transform/components/struct.Transform.html#structfield.translation -//! [`Entity`]: https://docs.rs/bevy/0.8.0/bevy/ecs/entity/struct.Entity.html -//! [`Query`]: https://docs.rs/bevy/0.8.0/bevy/ecs/system/struct.Query.html -//! [`ColorMaterial`]: https://docs.rs/bevy/0.8.0/bevy/sprite/struct.ColorMaterial.html -//! [`Sprite`]: https://docs.rs/bevy/0.8.0/bevy/sprite/struct.Sprite.html -//! [`Transform`]: https://docs.rs/bevy/0.8.0/bevy/transform/components/struct.Transform.html +//! [`Transform::translation`]: https://docs.rs/bevy/0.9.0/bevy/transform/components/struct.Transform.html#structfield.translation +//! [`Entity`]: https://docs.rs/bevy/0.9.0/bevy/ecs/entity/struct.Entity.html +//! [`Query`]: https://docs.rs/bevy/0.9.0/bevy/ecs/system/struct.Query.html +//! [`ColorMaterial`]: https://docs.rs/bevy/0.9.0/bevy/sprite/struct.ColorMaterial.html +//! [`Sprite`]: https://docs.rs/bevy/0.9.0/bevy/sprite/struct.Sprite.html +//! [`Transform`]: https://docs.rs/bevy/0.9.0/bevy/transform/components/struct.Transform.html use std::time::Duration; diff --git a/src/plugin.rs b/src/plugin.rs index 139467f..79537f4 100644 --- a/src/plugin.rs +++ b/src/plugin.rs @@ -29,11 +29,11 @@ use crate::{tweenable::ComponentTarget, Animator, AnimatorState, TweenCompleted} /// add manually the relevant systems for the exact set of components and assets /// actually animated. /// -/// [`Transform`]: https://docs.rs/bevy/0.8.0/bevy/transform/components/struct.Transform.html -/// [`Text`]: https://docs.rs/bevy/0.8.0/bevy/text/struct.Text.html -/// [`Style`]: https://docs.rs/bevy/0.8.0/bevy/ui/struct.Style.html -/// [`Sprite`]: https://docs.rs/bevy/0.8.0/bevy/sprite/struct.Sprite.html -/// [`ColorMaterial`]: https://docs.rs/bevy/0.8.0/bevy/sprite/struct.ColorMaterial.html +/// [`Transform`]: https://docs.rs/bevy/0.9.0/bevy/transform/components/struct.Transform.html +/// [`Text`]: https://docs.rs/bevy/0.9.0/bevy/text/struct.Text.html +/// [`Style`]: https://docs.rs/bevy/0.9.0/bevy/ui/struct.Style.html +/// [`Sprite`]: https://docs.rs/bevy/0.9.0/bevy/sprite/struct.Sprite.html +/// [`ColorMaterial`]: https://docs.rs/bevy/0.9.0/bevy/sprite/struct.ColorMaterial.html #[derive(Debug, Clone, Copy)] pub struct TweeningPlugin; @@ -146,11 +146,7 @@ mod tests { time.update(); world.insert_resource(time); - let entity = world - .spawn() - .insert(Transform::default()) - .insert(animator) - .id(); + let entity = world.spawn((Transform::default(), animator)).id(); Self { world, entity } } diff --git a/src/tweenable.rs b/src/tweenable.rs index 442f4fe..e8827c1 100644 --- a/src/tweenable.rs +++ b/src/tweenable.rs @@ -262,7 +262,8 @@ pub trait Tweenable<T>: Send + Sync { /// Get the total duration of the entire animation, including looping. /// - /// For [`TotalDuration::Finite`], this is the number of repeats times the duration of a single iteration ([`duration()`]). + /// For [`TotalDuration::Finite`], this is the number of repeats times the + /// duration of a single iteration ([`duration()`]). /// /// [`duration()`]: Tweenable::duration fn total_duration(&self) -> TotalDuration; @@ -968,7 +969,7 @@ impl<T> Delay<T> { pub fn new(duration: Duration) -> Self { assert!(!duration.is_zero()); Self { - timer: Timer::new(duration, false), + timer: Timer::new(duration, TimerMode::Once), on_completed: None, event_data: None, } @@ -1193,7 +1194,7 @@ mod tests { fn make_test_env() -> (World, Entity) { let mut world = World::new(); world.init_resource::<Events<TweenCompleted>>(); - let entity = world.spawn().insert(Transform::default()).id(); + let entity = world.spawn(Transform::default()).id(); (world, entity) } -- GitLab