Stores settings and other state for the playback of an animation on an {@link AnimationState} track.

References to a track entry must not be kept after the {@link AnimationStateListener#dispose(TrackEntry)} event occurs.

Constructor

new()

Variables

@:value(null)next:TrackEntry = null

@:value(null)mixingFrom:TrackEntry = null

@:value(null)mixingTo:TrackEntry = null

@:value(0)trackIndex:Int = 0

@:value(false)loop:Bool = false

@:value(false)holdPrevious:Bool = false

@:value(false)reverse:Bool = false

@:value(0)eventThreshold:Float = 0

@:value(0)animationStart:Float = 0

@:value(0)animationEnd:Float = 0

@:value(0)animationLast:Float = 0

@:value(0)nextAnimationLast:Float = 0

@:value(0)delay:Float = 0

@:value(0)trackTime:Float = 0

@:value(0)trackLast:Float = 0

@:value(0)nextTrackLast:Float = 0

@:value(0)trackEnd:Float = 0

@:value(0)timeScale:Float = 0

@:value(0)alpha:Float = 0

@:value(0)mixTime:Float = 0

@:value(0)mixDuration:Float = 0

@:value(0)interruptAlpha:Float = 0

@:value(0)totalAlpha:Float = 0

@:value(MixBlend.replace)mixBlend:MixBlend = MixBlend.replace

@:value(new IntArray())timelineMode:IntArray = new IntArray()

@:value(new Array())timelineHoldMix:Array<TrackEntry> = new Array()

@:value(new FloatArray())timelinesRotation:FloatArray = new FloatArray()

Methods

getTrackIndex():Int

The index of the track where this track entry is either current or queued.

See {@link AnimationState#getCurrent(int)}.

getAnimation():Animation

The animation to apply for this track entry.

getLoop():Bool

If true, the animation will repeat. If false it will not, instead its last frame is applied if played beyond its duration.

getDelay():Float

Seconds to postpone playing the animation. When this track entry is the current track entry, delay postpones incrementing the {@link #getTrackTime()}. When this track entry is queued, delay is the time from the start of the previous animation to when this track entry will become the current track entry (ie when the previous track entry {@link TrackEntry#getTrackTime()} >= this track entry's delay).

{@link #getTimeScale()} affects the delay.

When using {@link AnimationState#addAnimation(int, Animation, boolean, float)} with a delay <= 0, the delay is set using the mix duration from the {@link AnimationStateData}. If {@link #mixDuration} is set afterward, the delay may need to be adjusted.

getTrackTime():Float

Current time in seconds this track entry has been the current track entry. The track time determines {@link #getAnimationTime()}. The track time can be set to start the animation at a time other than 0, without affecting looping.

getTrackEnd():Float

The track time in seconds when this animation will be removed from the track. Defaults to the highest possible float value, meaning the animation will be applied until a new animation is set or the track is cleared. If the track end time is reached, no other animations are queued for playback, and mixing from any previous animations is complete, then the properties keyed by the animation are set to the setup pose and the track is cleared.

It may be desired to use {@link AnimationState#addEmptyAnimation(int, float, float)} rather than have the animation abruptly cease being applied.

getTrackComplete():Float

If this track entry is non-looping, the track time in seconds when {@link #getAnimationEnd()} is reached, or the current {@link #getTrackTime()} if it has already been reached. If this track entry is looping, the track time when this animation will reach its next {@link #getAnimationEnd()} (the next loop completion).

getAnimationStart():Float

Seconds when this animation starts, both initially and after looping. Defaults to 0.

When changing the animationStart time, it often makes sense to set {@link #getAnimationLast()} to the same value to prevent timeline keys before the start time from triggering.

setAnimationStart(animationStart:Float):Void

getAnimationEnd():Float

Seconds for the last frame of this animation. Non-looping animations won't play past this time. Looping animations will loop back to {@link #getAnimationStart()} at this time. Defaults to the animation {@link Animation#duration}.

setAnimationEnd(animationEnd:Float):Void

getAnimationLast():Float

The time in seconds this animation was last applied. Some timelines use this for one-time triggers. Eg, when this animation is applied, event timelines will fire all events between the animationLast time (exclusive) and animationTime (inclusive). Defaults to -1 to ensure triggers on frame 0 happen the first time this animation is applied.

setAnimationLast(animationLast:Float):Void

getAnimationTime():Float

Uses {@link #getTrackTime()} to compute the animationTime, which is between {@link #getAnimationStart()} and {@link #getAnimationEnd()}. When the trackTime is 0, the animationTime is equal to the animationStart time.

getTimeScale():Float

Multiplier for the delta time when this track entry is updated, causing time for this animation to pass slower or faster. Defaults to 1.

Values < 0 are not supported. To play an animation in reverse, use {@link #getReverse()}.

{@link #getMixTime()} is not affected by track entry time scale, so {@link #getMixDuration()} may need to be adjusted to match the animation speed.

When using {@link AnimationState#addAnimation(int, Animation, boolean, float)} with a delay <= 0, the {@link #getDelay()} is set using the mix duration from the {@link AnimationStateData}, assuming time scale to be 1. If the time scale is not 1, the delay may need to be adjusted.

See AnimationState {@link AnimationState#getTimeScale()} for affecting all animations.

getListener():AnimationStateListener

The listener for events generated by this track entry, or null.

A track entry returned from {@link AnimationState#setAnimation(int, Animation, boolean)} is already the current animation for the track, so the track entry listener {@link AnimationStateListener#start(TrackEntry)} will not be called.

getAlpha():Float

Values < 1 mix this animation with the skeleton's current pose (usually the pose resulting from lower tracks). Defaults to 1, which overwrites the skeleton's current pose with this animation.

Typically track 0 is used to completely pose the skeleton, then alpha is used on higher tracks. It doesn't make sense to use alpha on track 0 if the skeleton pose is from the last frame render.

getEventThreshold():Float

When the mix percentage ({@link #getMixTime()} / {@link #getMixDuration()}) is less than the eventThreshold, event timelines are applied while this animation is being mixed out. Defaults to 0, so event timelines are not applied while this animation is being mixed out.

setEventThreshold(eventThreshold:Float):Void

getAttachmentThreshold():Float

When the mix percentage ({@link #getMixTime()} / {@link #getMixDuration()}) is less than the attachmentThreshold, attachment timelines are applied while this animation is being mixed out. Defaults to 0, so attachment timelines are not applied while this animation is being mixed out.

setAttachmentThreshold(attachmentThreshold:Float):Void

getDrawOrderThreshold():Float

When the mix percentage ({@link #getMixTime()} / {@link #getMixDuration()}) is less than the drawOrderThreshold, draw order timelines are applied while this animation is being mixed out. Defaults to 0, so draw order timelines are not applied while this animation is being mixed out.

setDrawOrderThreshold(drawOrderThreshold:Float):Void

getNext():TrackEntry

The animation queued to start after this animation, or null if there is none. next makes up a doubly linked list.

See {@link AnimationState#clearNext(TrackEntry)} to truncate the list.

getPrevious():TrackEntry

The animation queued to play before this animation, or null. previous makes up a doubly linked list.

isComplete():Bool

Returns true if at least one loop has been completed.

See {@link AnimationStateListener#complete(TrackEntry)}.

getMixTime():Float

Seconds from 0 to the {@link #getMixDuration()} when mixing from the previous animation to this animation. May be slightly more than mixDuration when the mix is complete.

getMixDuration():Float

Seconds for mixing from the previous animation to this animation. Defaults to the value provided by AnimationStateData {@link AnimationStateData#getMix(Animation, Animation)} based on the animation before this animation (if any).

A mix duration of 0 still mixes out over one frame to provide the track entry being mixed out a chance to revert the properties it was animating.

The mixDuration can be set manually rather than use the value from {@link AnimationStateData#getMix(Animation, Animation)}. In that case, the mixDuration can be set for a new track entry only before {@link AnimationState#update(float)} is first called.

When using {@link AnimationState#addAnimation(int, Animation, boolean, float)} with a delay <= 0, the {@link #getDelay()} is set using the mix duration from the {@link AnimationStateData}. If mixDuration is set afterward, the delay may need to be adjusted. For example: entry.delay = entry.previous.getTrackComplete() - entry.mixDuration;

getMixBlend():MixBlend

Controls how properties keyed in the animation are mixed with lower tracks. Defaults to {@link MixBlend#replace}.

Track entries on track 0 ignore this setting and always use {@link MixBlend#first}.

The mixBlend can be set for a new track entry only before {@link AnimationState#apply(Skeleton)} is first called.

getMixingFrom():TrackEntry

The track entry for the previous animation when mixing from the previous animation to this animation, or null if no mixing is currently occuring. When mixing from multiple animations, mixingFrom makes up a linked list.

getMixingTo():TrackEntry

The track entry for the next animation when mixing from this animation to the next animation, or null if no mixing is currently occuring. When mixing to multiple animations, mixingTo makes up a linked list.

setHoldPrevious(holdPrevious:Bool):Void

getHoldPrevious():Bool

If true, when mixing from the previous animation to this animation, the previous animation is applied as normal instead of being mixed out.

When mixing between animations that key the same property, if a lower track also keys that property then the value will briefly dip toward the lower track value during the mix. This happens because the first animation mixes from 100% to 0% while the second animation mixes from 0% to 100%. Setting holdPrevious to true applies the first animation at 100% during the mix so the lower track value is overwritten. Such dipping does not occur on the lowest track which keys the property, only when a higher track also keys the property.

Snapping will occur if holdPrevious is true and this animation does not key all the same properties as the previous animation.

resetRotationDirections():Void

Resets the rotation directions for mixing this entry's rotate timelines. This can be useful to avoid bones rotating the long way around when using {@link #alpha} and starting animations on other tracks.

Mixing with {@link MixBlend#replace} involves finding a rotation between two others, which has two possible solutions: the short way or the long way around. The two rotations likely change over time, so which direction is the short or long way also changes. If the short way was always chosen, bones would flip to the other side when that direction became the long way. TrackEntry chooses the short way the first time it is applied and remembers that direction.

getReverse():Bool

If true, the animation will be applied in reverse. Events are not fired when an animation is applied in reverse.

isEmptyAnimation():Bool

Returns true if this entry is for the empty animation. See {@link AnimationState#setEmptyAnimation(int, float)}, {@link AnimationState#addEmptyAnimation(int, float, float)}, and {@link AnimationState#setEmptyAnimations(float)}.