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
+## `AnimationPlayer` API Improvements + + + +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