handle skip to end of animation

main
Elijah C. Voigt 2 years ago
parent 52f978e70a
commit 0cf4fe4fb6

@ -1397,14 +1397,22 @@ fn animate_title_light_in(
mut t: Local<Timer>, mut t: Local<Timer>,
mut started: Local<bool>, mut started: Local<bool>,
time: Res<Time>, time: Res<Time>,
keys: Res<ButtonInput<KeyCode>>,
mouse: Res<ButtonInput<MouseButton>>,
) { ) {
// Over 6 seconds, fade in to 600 intensity // Over 6 seconds, fade in to 600 intensity
if !(*started) { if !(*started) {
*t = Timer::from_seconds(6.0, TimerMode::Once); *t = Timer::from_seconds(6.0, TimerMode::Once);
*started = true *started = true
} else {
let skip = keys.just_pressed(KeyCode::Enter) || mouse.just_pressed(MouseButton::Left);
if skip {
t.tick(Duration::from_secs(6));
} else { } else {
t.tick(time.delta()); t.tick(time.delta());
} }
}
info!("Spotlight in"); info!("Spotlight in");
@ -1431,14 +1439,22 @@ fn animate_title_light_out(
mut t: Local<Timer>, mut t: Local<Timer>,
mut started: Local<bool>, mut started: Local<bool>,
time: Res<Time>, time: Res<Time>,
keys: Res<ButtonInput<KeyCode>>,
mouse: Res<ButtonInput<MouseButton>>,
) { ) {
// Over 6 seconds, fade in to 600 intensity // Over 6 seconds, fade in to 600 intensity
if !(*started) { if !(*started) {
*t = Timer::from_seconds(3.0, TimerMode::Once); *t = Timer::from_seconds(3.0, TimerMode::Once);
*started = true *started = true
} else {
let skip = keys.just_pressed(KeyCode::Enter) || mouse.just_pressed(MouseButton::Left);
if skip {
t.tick(Duration::from_secs(3));
} else { } else {
t.tick(time.delta()); t.tick(time.delta());
} }
}
info!("Spotlight out"); info!("Spotlight out");

Loading…
Cancel
Save