Skip to content

Commit 4967351

Browse files
committed
many foxes: only change animation once (#5076)
# Objective - When changing animation, all the foxes didn't play the same animation ## Solution - Update the animation index only once
1 parent 86dd6f0 commit 4967351

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

examples/stress_tests/many_foxes.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,10 @@ fn keyboard_animation_control(
229229
foxes.speed *= 0.8;
230230
}
231231

232+
if keyboard_input.just_pressed(KeyCode::Return) {
233+
*current_animation = (*current_animation + 1) % animations.0.len();
234+
}
235+
232236
for mut player in animation_player.iter_mut() {
233237
if keyboard_input.just_pressed(KeyCode::Space) {
234238
if player.is_paused() {
@@ -259,7 +263,6 @@ fn keyboard_animation_control(
259263
}
260264

261265
if keyboard_input.just_pressed(KeyCode::Return) {
262-
*current_animation = (*current_animation + 1) % animations.0.len();
263266
player
264267
.play(animations.0[*current_animation].clone_weak())
265268
.repeat();

0 commit comments

Comments
 (0)