Skip to content

Commit f1bdcd1

Browse files
committed
Add fade out tween to smoke
1 parent bf670eb commit f1bdcd1

File tree

5 files changed

+32
-3
lines changed

5 files changed

+32
-3
lines changed

Cargo.lock

+11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ bevy_mod_picking = { version = "0.20", default-features = false, features = [
4343
"backend_bevy_ui",
4444
] }
4545
bevy_state = "0.14"
46+
bevy_tweening = "0.11"
4647
interpolation = "0.3"
4748
iyes_progress = "0.12"
4849
lazy-regex = { version = "3", features = ["lite"] }

src/animation.rs

+3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ pub mod offset;
33
pub mod transition;
44

55
use bevy::prelude::*;
6+
use bevy_tweening::TweeningPlugin;
67

78
pub(super) fn plugin(app: &mut App) {
9+
app.add_plugins(TweeningPlugin);
10+
811
app.add_plugins((backup::plugin, offset::plugin, transition::plugin));
912
}

src/game/actor/movement/input.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ fn record_movement_action(
2828
mut action_query: Query<(&ActionState<MovementAction>, &mut MovementController)>,
2929
) {
3030
for (action, mut controller) in &mut action_query {
31-
let input = cq!(action.axis_pair(&MovementAction::Move));
32-
controller.0 = input.xy().clamp_length_max(1.0);
31+
controller.0 += cq!(action.axis_pair(&MovementAction::Move))
32+
.xy()
33+
.clamp_length_max(1.0);
3334
}
3435
}
3536

src/game/actor/movement/smoke.rs

+14-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
use std::time::Duration;
2+
13
use avian2d::prelude::*;
24
use bevy::ecs::system::EntityCommand;
35
use bevy::prelude::*;
6+
use bevy_tweening::*;
47

58
use crate::core::UpdateSet;
69
use crate::game::actor::movement::MovementController;
@@ -33,6 +36,8 @@ fn spawn_movement_smoke(
3336
}
3437
}
3538

39+
const LIFETIME_SECS: f32 = 0.5;
40+
3641
fn smoke(movement: Vec2) -> impl EntityCommand<World> {
3742
move |mut entity: EntityWorldMut| {
3843
let parent = entity.world().resource::<GameRoot>().vfx;
@@ -71,9 +76,17 @@ fn smoke(movement: Vec2) -> impl EntityCommand<World> {
7176
texture,
7277
..default()
7378
},
79+
Animator::new(Tween::new(
80+
EaseMethod::Linear,
81+
Duration::from_secs_f32(LIFETIME_SECS),
82+
lens::SpriteColorLens {
83+
start: Color::WHITE,
84+
end: Color::NONE,
85+
},
86+
)),
7487
RigidBody::Kinematic,
7588
LinearVelocity(-12.0 * movement),
76-
DespawnOnTimer(Timer::from_seconds(0.2, TimerMode::Once)),
89+
DespawnOnTimer(Timer::from_seconds(LIFETIME_SECS, TimerMode::Once)),
7790
))
7891
.set_parent(parent);
7992
}

0 commit comments

Comments
 (0)