Struct rusty_spine::TrackEntry

source ·
pub struct TrackEntry { /* private fields */ }
Expand description

Stores settings and other state for the playback of an animation on an AnimationState track.

Spine API Reference

Implementations§

source§

impl TrackEntry

source

pub fn animation_time(&self) -> f32

Uses track_time to compute the animation_time. When the track_time is 0, the animation_time is equal to the animation_start time.

The animation_time is between animation_start and animation_end, except if this track entry is non-looping and animation_end is >= to the animation duration, then animation_time continues to increase past animation_end.

source

pub fn track_complete(&self) -> f32

If this track entry is non-looping, the track time in seconds when animation_end is reached, or the current track_time if it has already been reached. If this track entry is looping, the track time when this animation will reach its next animation_end (the next loop completion).

source

pub fn animation(&self) -> CTmpRef<'_, Self, Animation>

The animation to apply for this track entry.

source

pub fn animation_mut(&mut self) -> CTmpMut<'_, Self, Animation>

The mutable animation to apply for this track entry.

source

pub fn previous(&self) -> Option<CTmpRef<'_, Self, TrackEntry>>

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

source

pub fn next(&self) -> Option<CTmpRef<'_, Self, TrackEntry>>

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

See AnimationState::clear_next to truncate the list.

source

pub fn mixing_from(&self) -> Option<CTmpRef<'_, Self, TrackEntry>>

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

source

pub fn mixing_to(&self) -> Option<CTmpRef<'_, Self, TrackEntry>>

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

source

pub fn track_index(&self) -> usize

source

pub fn looping(&self) -> bool

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

source

pub fn set_looping(&mut self, value: bool)

Set looping, see looping.

source

pub fn hold_previous(&self) -> 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 hold_previous 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 hold_previous is true and this animation does not key all the same properties as the previous animation.

source

pub fn set_hold_previous(&mut self, value: bool)

Set hold previous, see hold_previous.

source

pub fn reverse(&self) -> bool

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

source

pub fn set_reverse(&mut self, value: bool)

Set reverse, see reverse.

source

pub fn shortest_rotation(&self) -> bool

If true, mixing rotation between tracks always uses the shortest rotation direction. If the rotation is animated, the shortest rotation direction may change during the mix.

If false, the shortest rotation direction is remembered when the mix starts and the same direction is used for the rest of the mix.

Defaults to false.

source

pub fn set_shortest_rotation(&mut self, value: bool)

Set shortest rotation, see shortest_rotation.

source

pub fn event_threshold(&self) -> f32

When the mix percentage (mix_time / mix_duration) is less than the event_threshold, 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.

source

pub fn set_event_threshold(&mut self, value: f32)

Set the event threshold, see event_threshold.

source

pub fn attachment_threshold(&self) -> f32

When the mix percentage (mix_time / mix_duration) is less than the attachment_threshold, 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.

source

pub fn set_attachment_threshold(&mut self, value: f32)

Set the attachment threshold, see attachment_threshold.

source

pub fn draw_order_threshold(&self) -> f32

When the mix percentage (mix_time / mix_duration) is less than the draw_order_threshold, 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.

source

pub fn set_draw_order_threshold(&mut self, value: f32)

Set the draw order threshold, see draw_order_threshold.

source

pub fn animation_start(&self) -> f32

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

When changing the animationStart time, it often makes sense to set animation_last to the same value to prevent timeline keys before the start time from triggering.

source

pub fn set_animation_start(&mut self, value: f32)

Set the animation start, see animation_start.

source

pub fn animation_end(&self) -> f32

Seconds for the last frame of this animation. Non-looping animations won’t play past this time. Looping animations will loop back to animation_start at this time. Defaults to the animation duration.

source

pub fn set_animation_end(&mut self, value: f32)

Set the animation end, see animation_end.

source

pub fn animation_last(&self) -> f32

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.

source

pub fn set_animation_last(&mut self, value: f32)

Set the animation last, see animation_last.

source

pub fn delay(&self) -> f32

Seconds to postpone playing the animation. When this track entry is the current track entry, delay postpones incrementing the track_time. 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 track_time >= this track entry’s delay).

timescale affects the delay.

When using addAnimation with a delay <= 0, the delay is set using the mix duration from the AnimationStateData. If mixDuration is set afterward, the delay may need to be adjusted.

source

pub fn set_delay(&mut self, value: f32)

Set the delay, see delay.

source

pub fn track_time(&self) -> f32

Current time in seconds this track entry has been the current track entry. The track time determines animation_time. The track time can be set to start the animation at a time other than 0, without affecting looping.

source

pub fn track_end(&self) -> f32

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 AnimationState::add_empty_animation rather than have the animation abruptly cease being applied.

source

pub fn set_track_end(&mut self, value: f32)

Set the track end, see track_end.

source

pub fn timescale(&self) -> f32

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 set_reverse.

mix_time is not affected by track entry time scale, so mix_duration may need to be adjusted to match the animation speed.

When using AnimationState::add_animation with a delay <= 0, the delay is set using the mix duration from the AnimationStateData, assuming time scale to be 1. If the time scale is not 1, the delay may need to be adjusted.

See AnimationState::timescale for affecting all animations.

source

pub fn set_timescale(&mut self, value: f32)

Set the timescale, see timescale.

source

pub fn alpha(&self) -> f32

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.

source

pub fn set_alpha(&mut self, value: f32)

Set the alpha value, see alpha.

source

pub fn mix_time(&self) -> f32

Seconds from 0 to the mix_duration when mixing from the previous animation to this animation. May be slightly more than mix_duration when the mix is complete.

source

pub fn set_mix_time(&mut self, value: f32)

Set the mix time, see mix_time.

source

pub fn mix_duration(&self) -> f32

Seconds for mixing from the previous animation to this animation. Defaults to the value provided by AnimationStateData::get_mix 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 AnimationStateData::get_mix. In that case, the mix_duration can be set for a new track entry only before update is first called.

When using AnimationState::add_animation with a delay <= 0, the delay is set using the mix duration from the AnimationStateData. If mix_duration is set afterward, the delay may need to be adjusted.

For example:

entry.set_delay(entry.previous().unwrap().track_complete() - entry.mix_duration());
source

pub fn set_mix_duration(&mut self, value: f32)

Set the mix duration, see mix_duration.

source

pub fn total_alpha(&self) -> f32

source

pub fn renderer_object(&self) -> RendererObject<'_>

source

pub const fn c_ptr(&self) -> *mut spTrackEntry

Get a pointer to the underlying spine-c type.

Trait Implementations§

source§

impl Debug for TrackEntry

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl NewFromPtr<spTrackEntry> for TrackEntry

source§

unsafe fn new_from_ptr(c_track_entry: *mut spTrackEntry) -> Self

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.