AnimationState
spine.AnimationState (Class)
Applies animations over time, queues animations for later playback, mixes (crossfading) between animations, and applies
multiple animations on top of each other (layering).
See Applying Animations in the Spine Runtimes Guide.
Static Members
Instance Members
spine
animationsChanged: Bool
Increments each track entry {@link TrackEntry#getTrackTime()}, setting queued animations as current if needed.
Poses the skeleton using the track entry animations. The animation state is not changed, so can be applied to multiple
skeletons to pose them identically.
Returns |
Description |
Bool |
True if any animations were applied. |
Removes all animations from all tracks, leaving skeletons in their current pose.
It may be desired to use {@link AnimationState#setEmptyAnimations(float)} to mix the skeletons back to the setup pose,
rather than leaving them in their current pose.
spine
clearTrack(trackIndex: Int): Void
Removes all animations from the track, leaving skeletons in their current pose.
It may be desired to use {@link AnimationState#setEmptyAnimation(int, float)} to mix the skeletons back to the setup pose,
rather than leaving them in their current pose.
Sets an animation by name.
See {@link #setAnimation(int, Animation, boolean)}.
Sets the current animation for a track, discarding any queued animations. If the formerly current track entry was never
applied to a skeleton, it is replaced (not mixed from).
@link TrackEntry#getTrackEnd()} determines when the track is cleared.
@link AnimationStateListener#dispose(TrackEntry)} event occurs.
Name |
Type |
Description |
trackIndex |
Int |
|
animation |
Animation |
|
loop |
Bool |
If true, the animation will repeat. If false it will not, instead its last frame is applied if played beyond its duration. In either case { |
Returns |
Description |
TrackEntry |
A track entry to allow further customization of animation playback. References to the track entry must not be kept after the { |
Queues an animation by name.
See {@link #addAnimation(int, Animation, boolean, float)}.
Adds an animation to be played after the current or last queued animation for a track. If the track is empty, it is
equivalent to calling {@link #setAnimation(int, Animation, boolean)}.
@link AnimationStateData}) plus the specified delay
(ie the mix
ends at (delay
= 0) or before (delay
< 0) the previous track entry duration). If the
previous entry is looping, its next loop completion is used instead of its duration.
@link AnimationStateListener#dispose(TrackEntry)} event occurs.
Returns |
Description |
TrackEntry |
A track entry to allow further customization of animation playback. References to the track entry must not be kept after the { |
Sets an empty animation for a track, discarding any queued animations, and sets the track entry's
{@link TrackEntry#getMixDuration()}. An empty animation has no timelines and serves as a placeholder for mixing in or out.
Mixing out is done by setting an empty animation with a mix duration using either {@link #setEmptyAnimation(int, float)},
{@link #setEmptyAnimations(float)}, or {@link #addEmptyAnimation(int, float, float)}. Mixing to an empty animation causes
the previous animation to be applied less and less over the mix duration. Properties keyed in the previous animation
transition to the value from lower tracks or to the setup pose value if no lower tracks key the property. A mix duration of
0 still mixes out over one frame.
Mixing in is done by first setting an empty animation, then adding an animation using
{@link #addAnimation(int, Animation, boolean, float)} with the desired delay (an empty animation has a duration of 0) and on
the returned track entry, set the {@link TrackEntry#setMixDuration(float)}. Mixing from an empty animation causes the new
animation to be applied more and more over the mix duration. Properties keyed in the new animation transition from the value
from lower tracks or from the setup pose value if no lower tracks key the property to the value keyed in the new
animation.
Name |
Type |
trackIndex |
Int |
mixDuration |
Float |
Adds an empty animation to be played after the current or last queued animation for a track, and sets the track entry's
{@link TrackEntry#getMixDuration()}. If the track is empty, it is equivalent to calling
{@link #setEmptyAnimation(int, float)}.
See {@link #setEmptyAnimation(int, float)}.
@link AnimationStateListener#dispose(TrackEntry)} event occurs.
Name |
Type |
Description |
trackIndex |
Int |
|
mixDuration |
Float |
|
delay |
Float |
If > 0, sets { |
Returns |
Description |
TrackEntry |
A track entry to allow further customization of animation playback. References to the track entry must not be kept after the { |
spine
setEmptyAnimations(mixDuration: Float): Void
Sets an empty animation for every track, discarding any queued animations, and mixes to it over the specified mix
duration.
Name |
Type |
mixDuration |
Float |
Removes the {@link TrackEntry#getNext() next entry} and all entries after it for the specified entry.
spine
handleAnimationsChanged(): Void
Returns the track entry for the animation currently playing on the track, or null if no animation is currently playing.
Adds a listener to receive events for all track entries.
Removes the listener added with {@link #addListener(AnimationStateListener)}.
spine
clearListeners(): Void
Removes all listeners added with {@link #addListener(AnimationStateListener)}.
spine
clearListenerNotifications(): Void
Discards all listener notifications that have not yet been delivered. This can be useful to call from an
{@link AnimationStateListener} when it is known that further notifications that may have been already queued for delivery
are not wanted because new animations are being set.
spine
getTimeScale(): Float
Multiplier for the delta time when the animation state is updated, causing time for all animations and mixes to play slower
or faster. Defaults to 1.
See TrackEntry {@link TrackEntry#getTimeScale()} for affecting a single animation.
| Returns |
|---------|
| [Float](/api-docs/clay-native/Float/) |
Name |
Type |
timeScale |
Float |
The AnimationStateData to look up mix durations.
The list of tracks that have had animations, which may contain null entries for tracks that currently have no animation.
Creates an uninitialized AnimationState. The animation state data must be set before use.
Private Members
- A previously applied timeline has set this property.
Result: Mix from the current pose to the timeline pose.
- This is the first timeline to set this property.
- The next track entry applied after this one does not have a timeline to set this property.
Result: Mix from the setup pose to the timeline pose.
spine
HOLD_SUBSEQUENT: Int
- A previously applied timeline has set this property.
- The next track entry to be applied does have a timeline to set this property.
- The next track entry after that one does not have a timeline to set this property.
Result: Mix from the current pose to the timeline pose, but do not mix out. This avoids "dipping" when crossfading
animations that key the same property. A subsequent timeline will set this property using a mix.
- This is the first timeline to set this property.
- The next track entry to be applied does have a timeline to set this property.
- The next track entry after that one does not have a timeline to set this property.
Result: Mix from the setup pose to the timeline pose, but do not mix out. This avoids "dipping" when crossfading animations
that key the same property. A subsequent timeline will set this property using a mix.
- This is the first timeline to set this property.
- The next track entry to be applied does have a timeline to set this property.
- The next track entry after that one does have a timeline to set this property.
- timelineHoldMix stores the first subsequent track entry that does not have a timeline to set this property.
Result: The same as HOLD except the mix percentage from the timelineHoldMix track entry is used. This handles when more than
2 track entries in a row have a timeline that sets the same property.
Eg, A -> B -> C -> D where A, B, and C have a timeline setting same property, but D does not. When A is applied, to avoid
"dipping" A is not mixed out, however D (the first entry that doesn't set the property) mixing in is used to mix out A
(which affects B and C). Without using D to mix out, A would be applied fully until mixing completes, then snap to the mixed
out position.
Returns true when all mixing from entries are complete.
Applies the attachment timeline and sets {@link Slot#attachmentState}.
Name |
Type |
Description |
timeline |
AttachmentTimeline |
|
skeleton |
Skeleton |
|
time |
Float |
|
blend |
MixBlend |
|
attachments |
Bool |
False when: 1) the attachment timeline is mixing out, 2) mix < attachmentThreshold, and 3) the timeline is not the last timeline to set the slot's attachment. In that case the timeline is applied only so subsequent timelines see any deform. |
Applies the rotate timeline, mixing with the current pose while keeping the same rotation direction chosen as the shortest
the first time the mixing was applied.
spine
trackEntry(trackIndex: Int, animation: Animation, loop: Bool, last: TrackEntry): TrackEntry