From 12220c11d06ed83b92bdd39c178996400d9c3731 Mon Sep 17 00:00:00 2001 From: DevinLeamy Date: Thu, 26 Oct 2023 21:49:32 -0400 Subject: [PATCH] 0.12 AnimationPlayer updates section (#761) Co-authored-by: Alice Cecile Co-authored-by: Carter Anderson --- content/news/2023-10-21-bevy-0.12/index.md | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/content/news/2023-10-21-bevy-0.12/index.md b/content/news/2023-10-21-bevy-0.12/index.md index acb5c3fa0f..0c45112f0a 100644 --- a/content/news/2023-10-21-bevy-0.12/index.md +++ b/content/news/2023-10-21-bevy-0.12/index.md @@ -19,6 +19,32 @@ Since our last release a few months ago we've added a _ton_ of new features, bug
authors: @author
+## `AnimationPlayer` API Improvements + +
authors: @devinleamy
+ +The `AnimationPlayer` now has new methods for controlling playback, and utilities for checking +if an animation is playing or completed, and getting its `AnimationClip` handle. + +`set_elapsed` and has been removed in favor of `seek_to`. `elapsed` now +returns the actual elapsed time and is not affected by the animation speed. `stop_repeating` have been removed +in favor of `set_repeat(RepeatAnimation::Never)`. + +```rust +let mut player = q_animation_player.single_mut(); +// Check if an animation is complete. +if player.is_finished() { + // Set the playback mode. + player.set_repeat(RepeatAnimation::Forever); + player.set_repeat(RepeatAnimation::Never); + player.set_repeat(RepeatAnimation::Count(4)); +} +// Get a handle to the playing AnimationClip. +let clip_handle = player.animation_clip(); +// Seek to 1s in the current clip. +player.seek_to(1.0); +``` + ## Ignore Ambiguous Components and Resources
authors: @hymm