Skip to content

Commit 1f37772

Browse files
committed
Refactor
1 parent 85a7c20 commit 1f37772

2 files changed

Lines changed: 39 additions & 42 deletions

File tree

examples/demo/click.rs

Lines changed: 39 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -40,46 +40,45 @@ fn click_spawn_circle(
4040
) {
4141
use interpolate::sprite_color;
4242
let circle_filled_image = asset_server.load("circle_filled.png");
43-
if let Some(coord) = coord.0 {
44-
if key.just_pressed(MouseButton::Left)
45-
|| key.pressed(MouseButton::Right)
46-
{
47-
let start = Vec3::new(coord.x, coord.y, 1.);
48-
let end = Vec3::new(0., 0., 0.);
49-
let transform = Transform::from_translation(start);
50-
let circle = AnimationTarget.into_target();
51-
let mut circle_transform = circle.transform_state(transform);
52-
commands
53-
.spawn((
54-
Sprite {
55-
image: circle_filled_image,
56-
..default()
57-
},
58-
transform,
59-
AnimationTarget,
60-
))
61-
.animation()
62-
.insert(parallel((
63-
tween(
64-
secs(2.),
65-
EaseKind::ExponentialOut,
66-
circle_transform.translation_to(end),
67-
),
68-
tween(
69-
secs(1.),
70-
EaseKind::BackIn,
71-
circle_transform.scale_to(Vec3::ZERO),
72-
),
73-
tween(
74-
secs(1.),
75-
EaseKind::Linear,
76-
circle.with(sprite_color(
77-
into_color(WHITE),
78-
into_color(DEEP_PINK),
79-
)),
80-
),
81-
)));
82-
}
43+
if let Some(coord) = coord.0
44+
&& (key.just_pressed(MouseButton::Left)
45+
|| key.pressed(MouseButton::Right))
46+
{
47+
let start = Vec3::new(coord.x, coord.y, 1.);
48+
let end = Vec3::new(0., 0., 0.);
49+
let transform = Transform::from_translation(start);
50+
let circle = AnimationTarget.into_target();
51+
let mut circle_transform = circle.transform_state(transform);
52+
commands
53+
.spawn((
54+
Sprite {
55+
image: circle_filled_image,
56+
..default()
57+
},
58+
transform,
59+
AnimationTarget,
60+
))
61+
.animation()
62+
.insert(parallel((
63+
tween(
64+
secs(2.),
65+
EaseKind::ExponentialOut,
66+
circle_transform.translation_to(end),
67+
),
68+
tween(
69+
secs(1.),
70+
EaseKind::BackIn,
71+
circle_transform.scale_to(Vec3::ZERO),
72+
),
73+
tween(
74+
secs(1.),
75+
EaseKind::Linear,
76+
circle.with(sprite_color(
77+
into_color(WHITE),
78+
into_color(DEEP_PINK),
79+
)),
80+
),
81+
)));
8382
}
8483
}
8584

examples/demo/sprite_sheet.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ mod interpolate {
55
use bevy::{ecs::schedule::ScheduleLabel, prelude::*};
66
use bevy_tween::prelude::*;
77

8-
pub use bevy_tween::interpolate::*;
9-
108
pub fn custom_interpolators_plugin(app: &mut App) {
119
app.add_tween_systems(
1210
PostUpdate.intern(),

0 commit comments

Comments
 (0)