Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
# Changelog

## v0.8.1 - 2025-07-14
## v0.9.1 - 2025-07-15

- Fix color delta interpolation

### Breaking Change

- Add a delta flag to the built-in tweens
- This comes instead of the additional XDelta type so that one won't have to register so twice the types

## v0.9.0 - 2025-07-14

### Breaking Changes

Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "bevy_tween"
description = "Flexible tweening plugin library for Bevy"
version = "0.9.0"
version = "0.9.1"
edition = "2024"
authors = ["Multirious", "Rabbival"]
license = "MIT OR Apache-2.0"
Expand All @@ -23,7 +23,7 @@ default-features = false
features = ["std"]

[dependencies.bevy_math]
version = "0.16.0"
version = "0.16.1"
default-features = false
features = ["curve"]

Expand Down
26 changes: 20 additions & 6 deletions examples/demo/delta_tweens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ use std::time::Duration;
use bevy::{
prelude::*,
};
use bevy::color::palettes::basic::WHITE;
use bevy::color::palettes::css::{BLUE, RED};
use bevy_tween::{
combinator::*, prelude::*,
tween::AnimationTarget,
};
use bevy_tween::interpolate::{sprite_color_delta_to};

fn secs(secs: f32) -> Duration {
Duration::from_secs_f32(secs)
Expand Down Expand Up @@ -36,13 +39,14 @@ fn spawn_circle_with_tweens(
let float_duration = secs(4.0);
let circle = AnimationTarget.into_target();
let mut circle_transform_state = circle.transform_state(circle_transform);
let mut circle_sprite_state = circle.state(WHITE.into());

let mut circle_commands = commands
.spawn((
Sprite {
image: circle_filled_image,
..default()
},
Sprite {
image: circle_filled_image,
..default()
},
circle_transform,
AnimationTarget,
));
Expand All @@ -60,6 +64,16 @@ fn spawn_circle_with_tweens(
float_duration,
EaseKind::SineInOut,
circle_transform_state.translation_delta_by(vertical_delta),
)
),
tween(
float_duration,
EaseKind::Linear,
circle_sprite_state.with(sprite_color_delta_to(BLUE.into())),
),
tween(
float_duration,
EaseKind::CubicIn,
circle_sprite_state.with(sprite_color_delta_to(RED.into())),
)
)));
}
}
4 changes: 1 addition & 3 deletions examples/demo/follow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ fn main() {
.add_plugins((
DefaultPlugins,
DefaultTweenPlugins,
EguiPlugin {
enable_multipass_for_primary_context: false,
},
EguiPlugin::default(),
ResourceInspectorPlugin::<Config>::new(),
))
.add_systems(Startup, setup)
Expand Down
28 changes: 11 additions & 17 deletions examples/entity_structure.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use bevy::prelude::*;
use bevy_tween::interpolate::{AngleZ, Translation};
use bevy_tween::interpolate::{translation, AngleZ, Translation};
use bevy_tween::prelude::*;
use bevy_tween::{
bevy_time_runner::{TimeRunner, TimeSpan},
Expand Down Expand Up @@ -52,16 +52,14 @@ fn setup(mut commands: Commands) {
EaseKind::QuadraticInOut,
ComponentTween::new_target(
TargetComponent::marker(),
Translation {
start: Vec3::new(start_x, y, 0.),
end: Vec3::new(end_x, y, 0.),
},
translation(Vec3::new(start_x, y, 0.), Vec3::new(end_x, y, 0.))
),
ComponentTween::new_target(
TargetComponent::marker(),
AngleZ {
start: angle_start,
end: angle_end,
delta: false
},
),
));
Expand Down Expand Up @@ -93,16 +91,14 @@ fn setup(mut commands: Commands) {
EaseKind::QuadraticInOut,
ComponentTween::new_target(
TargetComponent::marker(),
Translation {
start: Vec3::new(start_x, y, 0.),
end: Vec3::new(end_x, y, 0.),
},
translation(Vec3::new(start_x, y, 0.), Vec3::new(end_x, y, 0.))
),
ComponentTween::new_target(
TargetComponent::marker(),
AngleZ {
start: angle_start,
end: angle_end,
delta: false
},
),
));
Expand Down Expand Up @@ -132,16 +128,14 @@ fn setup(mut commands: Commands) {
EaseKind::QuadraticInOut,
ComponentTween::new_target(
TargetComponent::marker(),
Translation {
start: Vec3::new(start_x, y, 0.),
end: Vec3::new(end_x, y, 0.),
},
translation(Vec3::new(start_x, y, 0.), Vec3::new(end_x, y, 0.))
),
ComponentTween::new_target(
TargetComponent::marker(),
AngleZ {
start: angle_start,
end: angle_end,
delta: false
},
),
));
Expand Down Expand Up @@ -176,13 +170,15 @@ fn setup(mut commands: Commands) {
Translation {
start: Vec3::new(start_x, y, 0.),
end: Vec3::new(end_x, y, 0.),
delta: false
},
),
ComponentTween::new_target(
TargetComponent::marker(),
AngleZ {
start: angle_start,
end: angle_end,
delta: false
},
),
));
Expand Down Expand Up @@ -216,16 +212,14 @@ fn setup(mut commands: Commands) {
EaseKind::QuadraticInOut,
ComponentTween::new_target(
sprite,
Translation {
start: Vec3::new(start_x, y, 0.),
end: Vec3::new(end_x, y, 0.),
},
translation(Vec3::new(start_x, y, 0.), Vec3::new(end_x, y, 0.))
),
ComponentTween::new_target(
sprite,
AngleZ {
start: angle_start,
end: angle_end,
delta: false
},
),
));
Expand Down
6 changes: 3 additions & 3 deletions src/combinator/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,17 +172,17 @@ impl TransformTargetState {
}

/// Create delta [`ComponentTween`] of transform's translation tweening by provided input
pub fn translation_delta_by(&mut self, by: Vec3) -> ComponentTween<TranslationDelta> {
pub fn translation_delta_by(&mut self, by: Vec3) -> ComponentTween<Translation> {
self.translation_with(translation_delta_by(by))
}

/// Create delta [`ComponentTween`] of transform's rotation tweening by provided input
pub fn rotation_delta_by(&mut self, by: Quat) -> ComponentTween<RotationDelta> {
pub fn rotation_delta_by(&mut self, by: Quat) -> ComponentTween<Rotation> {
self.rotation_with(rotation_delta_by(by))
}

/// Create delta [`ComponentTween`] of scale's rotation tweening by provided input
pub fn scale_delta_by(&mut self, by: Vec3) -> ComponentTween<ScaleDelta> {
pub fn scale_delta_by(&mut self, by: Vec3) -> ComponentTween<Scale> {
self.scale_with(scale_delta_by(by))
}
}
25 changes: 4 additions & 21 deletions src/interpolate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
//! - [`AngleZ`]
//! - [`SpriteColor`]
//! - [`ColorMaterial`]
//! - All their delta variants (such as [`TranslationDelta`])
//!
//! # Your own [`Interpolator`]
//!
Expand Down Expand Up @@ -218,47 +217,31 @@ impl Plugin for DefaultInterpolatorsPlugin {
tween::component_tween_system::<Rotation>(),
tween::component_tween_system::<Scale>(),
tween::component_tween_system::<AngleZ>(),
tween::component_tween_system::<TranslationDelta>(),
tween::component_tween_system::<RotationDelta>(),
tween::component_tween_system::<ScaleDelta>(),
tween::component_tween_system::<AngleZDelta>()
))
.register_type::<tween::ComponentTween<Translation>>()
.register_type::<tween::ComponentTween<Rotation>>()
.register_type::<tween::ComponentTween<Scale>>()
.register_type::<tween::ComponentTween<AngleZ>>()
.register_type::<tween::ComponentTween<TranslationDelta>>()
.register_type::<tween::ComponentTween<RotationDelta>>()
.register_type::<tween::ComponentTween<ScaleDelta>>()
.register_type::<tween::ComponentTween<AngleZDelta>>();
.register_type::<tween::ComponentTween<AngleZ>>();

#[cfg(feature = "bevy_sprite")]
app.add_tween_systems((
tween::component_tween_system::<SpriteColor>(),
tween::component_tween_system::<SpriteColorDelta>(),
))
.register_type::<tween::ComponentTween<SpriteColor>>()
.register_type::<tween::ComponentTween<SpriteColorDelta>>();
.register_type::<tween::ComponentTween<SpriteColor>>();

#[cfg(feature = "bevy_ui")]
app.add_tween_systems((
tween::component_tween_system::<ui::BackgroundColor>(),
tween::component_tween_system::<ui::BorderColor>(),
tween::component_tween_system::<BackgroundColorDelta>(),
tween::component_tween_system::<BorderColorDelta>(),
))
.register_type::<tween::ComponentTween<ui::BackgroundColor>>()
.register_type::<tween::ComponentTween<ui::BorderColor>>()
.register_type::<tween::ComponentTween<BackgroundColorDelta>>()
.register_type::<tween::ComponentTween<BorderColorDelta>>();
.register_type::<tween::ComponentTween<ui::BorderColor>>();

#[cfg(all(feature = "bevy_sprite", feature = "bevy_asset",))]
app.add_tween_systems((
tween::asset_tween_system::<sprite::ColorMaterial>(),
tween::asset_tween_system::<ColorMaterialDelta>(),
))
.register_type::<tween::AssetTween<sprite::ColorMaterial>>()
.register_type::<tween::ComponentTween<ColorMaterialDelta>>();
.register_type::<tween::AssetTween<sprite::ColorMaterial>>();
}
}

Expand Down
Loading
Loading