From f2b2bc2c6563b041169f2f69060207a611f7ffe8 Mon Sep 17 00:00:00 2001 From: RenDaoEr Date: Mon, 2 Dec 2024 14:25:40 +0800 Subject: [PATCH 1/7] Bevy 0.15 support & Migrating from the interpolation library to Bevy EaseFunction --- Cargo.toml | 26 +++--- README.md | 53 +++++++++--- benchmarks/Cargo.toml | 2 +- benchmarks/benches/lens.rs | 13 +-- examples/colormaterial_color.rs | 20 ++--- examples/menu.rs | 84 +++++++++---------- examples/sequence.rs | 134 +++++++++++++++--------------- examples/sprite_color.rs | 13 ++- examples/text_color.rs | 45 +++++----- examples/transform_rotation.rs | 19 ++--- examples/transform_translation.rs | 9 +- examples/ui_position.rs | 33 ++++---- src/lens.rs | 88 ++++---------------- src/lib.rs | 23 +++-- src/plugin.rs | 28 ++++--- src/tweenable.rs | 22 ++--- 16 files changed, 278 insertions(+), 334 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 4493cef..dee6fc5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,10 @@ [package] name = "bevy_tweening" version = "0.11.0" -authors = ["François Mockers ", "Jerome Humbert "] +authors = [ + "François Mockers ", + "Jerome Humbert ", +] edition = "2021" description = "Tweening animation plugin for the Bevy game engine" repository = "https://github.com/djeedai/bevy_tweening" @@ -24,43 +27,42 @@ bevy_ui = ["bevy/bevy_ui", "bevy/bevy_render"] bevy_text = ["bevy/bevy_text", "bevy/bevy_render", "bevy/bevy_sprite"] [dependencies] -interpolation = "0.3" -bevy = { version = "0.14", default-features = false } +bevy = { version = "0.15", default-features = false } [dev-dependencies] -bevy-inspector-egui = "0.25" +bevy-inspector-egui = "0.28" [[example]] name = "menu" -required-features = [ "bevy_ui", "bevy_text", "bevy/bevy_winit" ] +required-features = ["bevy_ui", "bevy_text", "bevy/bevy_winit"] [[example]] name = "colormaterial_color" -required-features = [ "bevy_asset", "bevy_sprite", "bevy/bevy_winit" ] +required-features = ["bevy_asset", "bevy_sprite", "bevy/bevy_winit"] [[example]] name = "sprite_color" -required-features = [ "bevy_sprite", "bevy/bevy_winit" ] +required-features = ["bevy_sprite", "bevy/bevy_winit"] [[example]] name = "transform_translation" -required-features = [ "bevy_sprite", "bevy/bevy_winit" ] +required-features = ["bevy_sprite", "bevy/bevy_winit"] [[example]] name = "transform_rotation" -required-features = [ "bevy_sprite", "bevy/bevy_winit" ] +required-features = ["bevy_sprite", "bevy/bevy_winit"] [[example]] name = "ui_position" -required-features = [ "bevy_sprite", "bevy_ui", "bevy/bevy_winit" ] +required-features = ["bevy_sprite", "bevy_ui", "bevy/bevy_winit"] [[example]] name = "text_color" -required-features = [ "bevy_ui", "bevy_text", "bevy/bevy_winit" ] +required-features = ["bevy_ui", "bevy_text", "bevy/bevy_winit"] [[example]] name = "sequence" -required-features = [ "bevy_sprite", "bevy_text", "bevy/bevy_winit" ] +required-features = ["bevy_sprite", "bevy_text", "bevy/bevy_winit"] [workspace] resolver = "2" diff --git a/README.md b/README.md index 64669dc..3751dec 100644 --- a/README.md +++ b/README.md @@ -60,8 +60,8 @@ By default, 🍃 Bevy Tweening adopts a minimalist approach, and the `TweeningPl | `Transform` | Yes | | `Sprite` | Only if `bevy_sprite` feature | | `ColorMaterial` | Only if `bevy_sprite` feature | -| `Style` | Only if `bevy_ui` feature | -| `Text` | Only if `bevy_text` feature | +| `Node` | Only if `bevy_ui` feature | +| `TextColor` | Only if `bevy_text` feature | | All other components | No | To add a system for a component `C`, use: @@ -103,12 +103,9 @@ let tween = Tween::new( commands.spawn(( // Spawn a Sprite entity to animate the position of. - SpriteBundle { - sprite: Sprite { - color: Color::RED, - custom_size: Some(Vec2::new(size, size)), - ..default() - }, + Sprite { + color: Color::RED, + custom_size: Some(Vec2::new(size, size)), ..default() }, // Add an Animator component to control and execute the animation. @@ -168,7 +165,7 @@ Asset animation always requires the `bevy_asset` feature. | Target Asset | Animated Field | Lens | Feature | |---|---|---|---| -| [`ColorMaterial`](https://docs.rs/bevy/0.14.0/bevy/sprite/struct.ColorMaterial.html) | [`color`](https://docs.rs/bevy/0.14.0/bevy/sprite/struct.ColorMaterial.html#structfield.color) | [`ColorMaterialColorLens`](https://docs.rs/bevy_tweening/latest/bevy_tweening/lens/struct.ColorMaterialColorLens.html) | `bevy_asset` + `bevy_sprite` | +| [`ColorMaterial`](https://docs.rs/bevy/0.15.0/bevy/sprite/struct.ColorMaterial.html) | [`color`](https://docs.rs/bevy/0.14.0/bevy/sprite/struct.ColorMaterial.html#structfield.color) | [`ColorMaterialColorLens`](https://docs.rs/bevy_tweening/latest/bevy_tweening/lens/struct.ColorMaterialColorLens.html) | `bevy_asset` + `bevy_sprite` | ## Custom lens @@ -286,38 +283,74 @@ cargo run --example sequence --features="bevy/bevy_winit" ## Ease Functions -Many [ease functions](https://docs.rs/interpolation/0.2.0/interpolation/enum.EaseFunction.html) are available: +Many [ease functions](https://docs.rs/bevy/latest/bevy/math/curve/enum.EaseFunction.html) are available: +- Linear +> `f(t) = t` - QuadraticIn +> `f(t) = t²` - QuadraticOut +> `f(t) = -(t * (t - 2.0))` - QuadraticInOut +> Behaves as `EaseFunction::QuadraticIn` for t < 0.5 and as `EaseFunction::QuadraticOut` for t >= 0.5 - CubicIn +> `f(t) = t³` - CubicOut +> `f(t) = (t - 1.0)³ + 1.0` - CubicInOut +> Behaves as `EaseFunction::CubicIn` for t < 0.5 and as `EaseFunction::CubicOut` for t >= 0.5 - QuarticIn +> `f(t) = t⁴` - QuarticOut +> `f(t) = (t - 1.0)³ * (1.0 - t) + 1.0` - QuarticInOut +> Behaves as `EaseFunction::QuarticIn` for t < 0.5 and as `EaseFunction::QuarticOut` for t >= 0.5 - QuinticIn +> `f(t) = t⁵` - QuinticOut +> `f(t) = (t - 1.0)⁵ + 1.0` - QuinticInOut +> Behaves as `EaseFunction::QuinticIn` for t < 0.5 and as `EaseFunction::QuinticOut` for t >= 0.5 - SineIn +> `f(t) = 1.0 - cos(t * π / 2.0)` - SineOut +> `f(t) = sin(t * π / 2.0)` - SineInOut +> Behaves as `EaseFunction::SineIn` for t < 0.5 and as `EaseFunction::SineOut` for t >= 0.5 - CircularIn +> `f(t) = 1.0 - sqrt(1.0 - t²)` - CircularOut +> `f(t) = sqrt((2.0 - t) * t)` - CircularInOut +> Behaves as `EaseFunction::CircularIn` for t < 0.5 and as `EaseFunction::CircularOut` for t >= 0.5 - ExponentialIn +> `f(t) = 2.0^(10.0 * (t - 1.0))` - ExponentialOut +> `f(t) = 1.0 - 2.0^(-10.0 * t)` - ExponentialInOut +> Behaves as `EaseFunction::ExponentialIn` for t < 0.5 and as `EaseFunction::ExponentialOut` for t >= 0.5 - ElasticIn +> `f(t) = -2.0^(10.0 * t - 10.0) * sin((t * 10.0 - 10.75) * 2.0 * π / 3.0)` - ElasticOut +> `f(t) = 2.0^(-10.0 * t) * sin((t * 10.0 - 0.75) * 2.0 * π / 3.0) + 1.0` - ElasticInOut +> Behaves as `EaseFunction::ElasticIn` for t < 0.5 and as `EaseFunction::ElasticOut` for t >= 0.5 - BackIn +> `f(t) = 2.70158 * t³ - 1.70158 * t²` - BackOut +> `f(t) = 1.0 + 2.70158 * (t - 1.0)³ - 1.70158 * (t - 1.0)²` - BackInOut +> Behaves as `EaseFunction::BackIn` for t < 0.5 and as `EaseFunction::BackOut` for t >= 0.5 - BounceIn +> bouncy at the start! - BounceOut +> bouncy at the end! - BounceInOut +> Behaves as `EaseFunction::BounceIn` for t < 0.5 and as `EaseFunction::BounceOut` for t >= 0.5 +- Steps(usize) +> `n` steps connecting the start and the end +- Elastic(f32) +> `f(omega,t) = 1 - (1 - t)²(2sin(omega * t) / omega + cos(omega * t))`, parametrized by omega ## Compatible Bevy versions diff --git a/benchmarks/Cargo.toml b/benchmarks/Cargo.toml index a0b79cd..dc15cbc 100644 --- a/benchmarks/Cargo.toml +++ b/benchmarks/Cargo.toml @@ -18,7 +18,7 @@ criterion = { version = "0.5", features = ["html_reports"] } bevy_tweening = { path = "../" } [dependencies.bevy] -version = "0.14" +version = "0.15" default-features = false features = ["bevy_render", "bevy_sprite", "bevy_text", "bevy_ui"] diff --git a/benchmarks/benches/lens.rs b/benchmarks/benches/lens.rs index edd1f49..6bbf67f 100644 --- a/benchmarks/benches/lens.rs +++ b/benchmarks/benches/lens.rs @@ -13,21 +13,12 @@ fn text_color_lens(c: &mut Criterion) { let mut lens = TextColorLens { start: RED.into(), end: BLUE.into(), - section: 0, }; - let mut text = Text::from_section( - "test".to_string(), - TextStyle { - font: Default::default(), - font_size: 60.0, - color: Color::WHITE, - }, - ) - .with_justify(JustifyText::Center); + let mut text_color = TextColor::default(); let mut added = Tick::new(0); let mut last_changed = Tick::new(0); let mut target = ComponentTarget::new(Mut::new( - &mut text, + &mut text_color, &mut added, &mut last_changed, Tick::new(0), diff --git a/examples/colormaterial_color.rs b/examples/colormaterial_color.rs index 6f45119..5f17730 100644 --- a/examples/colormaterial_color.rs +++ b/examples/colormaterial_color.rs @@ -1,8 +1,4 @@ -use bevy::{ - color::palettes::css::*, - prelude::*, - sprite::{MaterialMesh2dBundle, Mesh2dHandle}, -}; +use bevy::{color::palettes::css::*, prelude::*}; use bevy_tweening::{lens::*, *}; use std::time::Duration; @@ -30,7 +26,7 @@ fn setup( mut meshes: ResMut>, mut materials: ResMut>, ) { - commands.spawn(Camera2dBundle::default()); + commands.spawn(Camera2d::default()); let size = 80.; @@ -40,7 +36,7 @@ fn setup( let mut x = -screen_x; let mut y = screen_y; - let quad_mesh: Mesh2dHandle = meshes.add(Rectangle::new(1., 1.)).into(); + let quad_mesh = meshes.add(Rectangle::new(1., 1.)); for ease_function in &[ EaseFunction::QuadraticIn, @@ -92,13 +88,9 @@ fn setup( .with_repeat_strategy(RepeatStrategy::MirroredRepeat); commands.spawn(( - MaterialMesh2dBundle { - mesh: quad_mesh.clone(), - transform: Transform::from_translation(Vec3::new(x, y, 0.)) - .with_scale(Vec3::splat(size)), - material: unique_material, - ..default() - }, + Mesh2d(quad_mesh.clone()), + MeshMaterial2d(unique_material), + Transform::from_translation(Vec3::new(x, y, 0.)).with_scale(Vec3::splat(size)), AssetAnimator::new(tween), )); y -= size * spacing; diff --git a/examples/menu.rs b/examples/menu.rs index 25d6660..b95204f 100644 --- a/examples/menu.rs +++ b/examples/menu.rs @@ -43,32 +43,29 @@ fn main() { } fn setup(mut commands: Commands, asset_server: Res) { - commands.spawn(Camera2dBundle::default()); + commands.spawn(Camera2d::default()); let font = asset_server.load("fonts/FiraMono-Regular.ttf"); commands .spawn(( - NodeBundle { - style: Style { - position_type: PositionType::Absolute, - left: Val::Px(0.), - right: Val::Px(0.), - top: Val::Px(0.), - bottom: Val::Px(0.), - margin: UiRect::all(Val::Px(16.)), - padding: UiRect::all(Val::Px(16.)), - flex_direction: FlexDirection::Column, - align_content: AlignContent::Center, - align_items: AlignItems::Center, - align_self: AlignSelf::Center, - justify_content: JustifyContent::Center, - ..default() - }, - background_color: BackgroundColor(Color::NONE), + Name::new("menu"), + Node { + position_type: PositionType::Absolute, + left: Val::Px(0.), + right: Val::Px(0.), + top: Val::Px(0.), + bottom: Val::Px(0.), + margin: UiRect::all(Val::Px(16.)), + padding: UiRect::all(Val::Px(16.)), + flex_direction: FlexDirection::Column, + align_content: AlignContent::Center, + align_items: AlignItems::Center, + align_self: AlignSelf::Center, + justify_content: JustifyContent::Center, ..default() }, - Name::new("menu"), + BackgroundColor(Color::NONE), )) .with_children(|container| { let mut start_time_ms = 0; @@ -98,39 +95,34 @@ fn setup(mut commands: Commands, asset_server: Res) { start_time_ms += 500; container .spawn(( - ButtonBundle { - style: Style { - min_width: Val::Px(300.), - min_height: Val::Px(80.), - margin: UiRect::all(Val::Px(8.)), - padding: UiRect::all(Val::Px(8.)), - align_content: AlignContent::Center, - align_items: AlignItems::Center, - align_self: AlignSelf::Center, - justify_content: JustifyContent::Center, - ..default() - }, - background_color: BackgroundColor(NORMAL_COLOR), - transform: Transform::from_scale(Vec3::splat(0.01)), + Name::new(format!("button:{}", text)), + Node { + min_width: Val::Px(300.), + min_height: Val::Px(80.), + margin: UiRect::all(Val::Px(8.)), + padding: UiRect::all(Val::Px(8.)), + align_content: AlignContent::Center, + align_items: AlignItems::Center, + align_self: AlignSelf::Center, + justify_content: JustifyContent::Center, ..default() }, - Name::new(format!("button:{}", text)), + BackgroundColor(NORMAL_COLOR), + Transform::from_scale(Vec3::splat(0.01)), animator, label, )) .with_children(|parent| { - parent.spawn(TextBundle { - text: Text::from_section( - text.to_string(), - TextStyle { - font: font.clone(), - font_size: 48.0, - color: TEXT_COLOR, - }, - ) - .with_justify(JustifyText::Center), - ..default() - }); + parent.spawn(( + Text::new(text.to_string()), + TextFont { + font: font.clone(), + font_size: 48.0, + ..default() + }, + TextColor(TEXT_COLOR), + TextLayout::new_with_justify(JustifyText::Center), + )); }); } }); diff --git a/examples/sequence.rs b/examples/sequence.rs index 5753ccf..a7c80e4 100644 --- a/examples/sequence.rs +++ b/examples/sequence.rs @@ -34,68 +34,67 @@ struct RedSprite; #[derive(Component)] struct BlueSprite; +#[derive(Component)] +struct ProgressValue; + fn setup(mut commands: Commands, asset_server: Res) { - commands.spawn(Camera2dBundle::default()); + commands.spawn(Camera2d::default()); let font = asset_server.load("fonts/FiraMono-Regular.ttf"); - let text_style_red = TextStyle { - font: font.clone(), - font_size: 50.0, - color: RED.into(), - }; - let text_style_blue = TextStyle { + let text_font = TextFont { font, font_size: 50.0, - color: BLUE.into(), + ..default() }; + let text_color_red = TextColor(RED.into()); + let text_color_blue = TextColor(BLUE.into()); + let justify = JustifyText::Center; // Text with the index of the active tween in the sequence - commands.spawn(( - Text2dBundle { - text: Text { - sections: vec![ - TextSection { - value: "progress: ".to_owned(), - style: text_style_red.clone(), - }, - TextSection { - value: "0%".to_owned(), - style: text_style_red, - }, - ], - justify, - ..default() - }, - transform: Transform::from_translation(Vec3::new(0., 40., 0.)), - ..default() - }, - RedProgress, - )); + commands + .spawn(( + Text2d::default(), + TextLayout::new_with_justify(justify), + Transform::from_translation(Vec3::new(0., 40., 0.)), + RedProgress, + )) + .with_children(|children| { + children.spawn(( + TextSpan::new("progress: "), + text_font.clone(), + text_color_red.clone(), + )); + children.spawn(( + TextSpan::new("0%"), + text_font.clone(), + text_color_red.clone(), + ProgressValue, + )); + }); // Text with progress of the active tween in the sequence - commands.spawn(( - Text2dBundle { - text: Text { - sections: vec![ - TextSection { - value: "progress: ".to_owned(), - style: text_style_blue.clone(), - }, - TextSection { - value: "0%".to_owned(), - style: text_style_blue, - }, - ], - justify, - ..default() - }, - transform: Transform::from_translation(Vec3::new(0., -40., 0.)), - ..default() - }, - BlueProgress, - )); + commands + .spawn(( + Text2d::default(), + TextLayout::new_with_justify(justify), + Transform::from_translation(Vec3::new(0., -40., 0.)), + BlueProgress, + )) + .with_children(|children| { + children.spawn(( + TextSpan::new("progress: "), + text_font.clone(), + text_color_blue.clone(), + )); + children.spawn(( + TextSpan::new("0%"), + text_font.clone(), + text_color_blue.clone(), + ProgressValue, + )); + }); let size = 25.; @@ -140,12 +139,9 @@ fn setup(mut commands: Commands, asset_server: Res) { })); commands.spawn(( - SpriteBundle { - sprite: Sprite { - color: RED.into(), - custom_size: Some(Vec2::new(size, size)), - ..default() - }, + Sprite { + color: RED.into(), + custom_size: Some(Vec2::new(size, size)), ..default() }, RedSprite, @@ -187,13 +183,10 @@ fn setup(mut commands: Commands, asset_server: Res) { let seq2 = Sequence::new([Box::new(tween_move) as BoxedTweenable<_>, tracks.into()]); commands.spawn(( - SpriteBundle { - sprite: Sprite { - color: BLUE.into(), - custom_size: Some(Vec2::new(size * 3., size)), - ..default() - }, - ..Default::default() + Sprite { + color: BLUE.into(), + custom_size: Some(Vec2::new(size * 3., size)), + ..default() }, BlueSprite, Animator::new(seq2), @@ -201,8 +194,9 @@ fn setup(mut commands: Commands, asset_server: Res) { } fn update_text( - mut query_text_red: Query<&mut Text, (With, Without)>, - mut query_text_blue: Query<&mut Text, (With, Without)>, + query_text_red: Query<&Children, (With, Without)>, + query_text_blue: Query<&Children, (With, Without)>, + mut text_spans: Query<&mut TextSpan, With>, query_anim_red: Query<&Animator, With>, query_anim_blue: Query<&Animator, With>, mut query_event: EventReader, @@ -213,11 +207,13 @@ fn update_text( let anim_blue = query_anim_blue.single(); let progress_blue = anim_blue.tweenable().progress(); - let mut red_text = query_text_red.single_mut(); - red_text.sections[1].value = format!("{:5.1}%", progress_red * 100.); + let red_text_children = query_text_red.single(); + let mut red_text = text_spans.get_mut(red_text_children[1]).unwrap(); + red_text.0 = format!("{:5.1}%", progress_red * 100.); - let mut blue_text = query_text_blue.single_mut(); - blue_text.sections[1].value = format!("{:5.1}%", progress_blue * 100.); + let blue_text_children = query_text_blue.single(); + let mut blue_text = text_spans.get_mut(blue_text_children[1]).unwrap(); + blue_text.0 = format!("{:5.1}%", progress_blue * 100.); for ev in query_event.read() { println!( diff --git a/examples/sprite_color.rs b/examples/sprite_color.rs index 6c74782..14674a4 100644 --- a/examples/sprite_color.rs +++ b/examples/sprite_color.rs @@ -21,7 +21,7 @@ fn main() { } fn setup(mut commands: Commands) { - commands.spawn(Camera2dBundle::default()); + commands.spawn(Camera2d::default()); let size = 80.; @@ -75,15 +75,12 @@ fn setup(mut commands: Commands) { .with_repeat_strategy(RepeatStrategy::MirroredRepeat); commands.spawn(( - SpriteBundle { - transform: Transform::from_translation(Vec3::new(x, y, 0.)), - sprite: Sprite { - color: Color::BLACK, - custom_size: Some(Vec2::new(size, size)), - ..default() - }, + Sprite { + color: Color::BLACK, + custom_size: Some(Vec2::new(size, size)), ..default() }, + Transform::from_translation(Vec3::new(x, y, 0.)), Animator::new(tween), )); diff --git a/examples/text_color.rs b/examples/text_color.rs index 10c11a2..3a84e7b 100644 --- a/examples/text_color.rs +++ b/examples/text_color.rs @@ -24,7 +24,7 @@ fn main() { } fn setup(mut commands: Commands, asset_server: Res) { - commands.spawn(Camera2dBundle::default()); + commands.spawn(Camera2d::default()); let font = asset_server.load("fonts/FiraMono-Regular.ttf"); @@ -76,36 +76,31 @@ fn setup(mut commands: Commands, asset_server: Res) { TextColorLens { start: RED.into(), end: BLUE.into(), - section: 0, }, ) .with_repeat_count(RepeatCount::Infinite) .with_repeat_strategy(RepeatStrategy::MirroredRepeat); commands.spawn(( - TextBundle { - style: Style { - width: Val::Px(size_x), - height: Val::Px(size_y), - left: Val::Px(x), - top: Val::Px(y), - right: Val::Auto, - bottom: Val::Auto, - position_type: PositionType::Absolute, - align_content: AlignContent::Center, - align_items: AlignItems::Center, - align_self: AlignSelf::Center, - justify_content: JustifyContent::Center, - ..default() - }, - text: Text::from_section( - *ease_name, - TextStyle { - font: font.clone(), - font_size: 24.0, - color: Color::WHITE, - }, - ), + Text::new(*ease_name), + TextFont { + font: font.clone(), + font_size: 24.0, + ..default() + }, + TextColor(Color::WHITE), + Node { + width: Val::Px(size_x), + height: Val::Px(size_y), + left: Val::Px(x), + top: Val::Px(y), + right: Val::Auto, + bottom: Val::Auto, + position_type: PositionType::Absolute, + align_content: AlignContent::Center, + align_items: AlignItems::Center, + align_self: AlignSelf::Center, + justify_content: JustifyContent::Center, ..default() }, Animator::new(tween), diff --git a/examples/transform_rotation.rs b/examples/transform_rotation.rs index 54757bc..7dbfd67 100644 --- a/examples/transform_rotation.rs +++ b/examples/transform_rotation.rs @@ -38,7 +38,7 @@ impl Default for Options { } fn setup(mut commands: Commands) { - commands.spawn(Camera2dBundle::default()); + commands.spawn(Camera2d::default()); let size = 80.; @@ -92,18 +92,15 @@ fn setup(mut commands: Commands) { .with_repeat_strategy(RepeatStrategy::MirroredRepeat); commands - .spawn(SpatialBundle { - transform: Transform::from_translation(Vec3::new(x, y, 0.)), - ..default() - }) + .spawn(( + Transform::from_translation(Vec3::new(x, y, 0.)), + Visibility::default(), + )) .with_children(|parent| { parent.spawn(( - SpriteBundle { - sprite: Sprite { - color: RED.into(), - custom_size: Some(Vec2::new(size, size * 0.5)), - ..default() - }, + Sprite { + color: RED.into(), + custom_size: Some(Vec2::new(size, size * 0.5)), ..default() }, Animator::new(tween), diff --git a/examples/transform_translation.rs b/examples/transform_translation.rs index 7cce2a2..c0bd593 100644 --- a/examples/transform_translation.rs +++ b/examples/transform_translation.rs @@ -91,12 +91,9 @@ fn setup(mut commands: Commands) { .with_repeat_strategy(RepeatStrategy::MirroredRepeat); commands.spawn(( - SpriteBundle { - sprite: Sprite { - color: RED.into(), - custom_size: Some(Vec2::new(size, size)), - ..default() - }, + Sprite { + color: RED.into(), + custom_size: Some(Vec2::new(size, size)), ..default() }, Animator::new(tween), diff --git a/examples/ui_position.rs b/examples/ui_position.rs index c8b5699..6f87822 100644 --- a/examples/ui_position.rs +++ b/examples/ui_position.rs @@ -38,7 +38,7 @@ impl Default for Options { } fn setup(mut commands: Commands) { - commands.spawn(Camera2dBundle::default()); + commands.spawn(Camera2d::default()); let size = 25.; @@ -101,24 +101,21 @@ fn setup(mut commands: Commands) { .with_repeat_strategy(RepeatStrategy::MirroredRepeat); commands.spawn(( - NodeBundle { - style: Style { - width: Val::Px(size), - height: Val::Px(size), - left: Val::Px(x), - top: Val::Px(10.), - right: Val::Auto, - bottom: Val::Auto, - position_type: PositionType::Absolute, - align_content: AlignContent::Center, - align_items: AlignItems::Center, - align_self: AlignSelf::Center, - justify_content: JustifyContent::Center, - ..default() - }, - background_color: BackgroundColor(RED.into()), + Node { + width: Val::Px(size), + height: Val::Px(size), + left: Val::Px(x), + top: Val::Px(10.), + right: Val::Auto, + bottom: Val::Auto, + position_type: PositionType::Absolute, + align_content: AlignContent::Center, + align_items: AlignItems::Center, + align_self: AlignSelf::Center, + justify_content: JustifyContent::Center, ..default() }, + BackgroundColor(RED.into()), Animator::new(tween), )); @@ -126,7 +123,7 @@ fn setup(mut commands: Commands) { } } -fn update_animation_speed(options: Res, mut animators: Query<&mut Animator