AnimationEvents
Notable milestones that the framework signals during animation playback.
Declaration
enum AnimationEventsOverview
This enumeration defines the playback states that an animated entity can indicate to an app. To receive notification of a particular event, create a completion handler:
private func onAnimationCompleted(_ event:
AnimationEvents.PlaybackCompleted) {
// Define code that runs when the animation completes.
}Then, subscribe the handler on the entity for the state of interest:
// Get an animation.
let animationName =
entity.availableAnimations.first!.name!
// Pass the animation to an entity and get a controller.
entity.playAnimation(named: animationName, transitionDuration: 0.0)
entitySubscription = view.scene.publisher(for:
AnimationEvents.PlaybackCompleted.self, on: entity)
.sink(receiveValue: onAnimationCompleted)Topics
Recognizing animation events
AnimationEvents.PlaybackStartedAnimationEvents.PlaybackCompletedAnimationEvents.PlaybackLoopedAnimationEvents.PlaybackTerminated