Overview
RiveLinearAnimationInstance represents an instance of a linear animation within a Rive artboard. It provides control over animation playback, including time manipulation, looping, direction, and playback state.
Time Control
time
Returns the current time position of the animation in seconds.The current time in seconds.
setTime:
Sets the current time position of the animation.The time in seconds to set the animation to.
endTime
Returns the end time of the animation in seconds.The end time in seconds.
Playback Control
advanceBy:
Advances the animation by the specified elapsed time.The time in seconds to advance the animation.
Returns true if the animation is still playing, false if it has ended.
direction (getter)
Returns the current playback direction of the animation.The direction value: 1 for forward, -1 for backward.
direction: (setter)
Sets the playback direction of the animation.The direction to set: 1 for forward, -1 for backward.
Loop Control
loop (getter)
Returns the current loop mode of the animation.The loop mode value. Common values:
- 0: One-shot (no looping)
- 1: Loop (repeat from start)
- 2: Ping-pong (reverse direction on each loop)
loop: (setter)
Sets the loop mode of the animation.The loop mode to set:
- 0: One-shot (no looping)
- 1: Loop (repeat from start)
- 2: Ping-pong (reverse direction on each loop)
didLoop
Returns whether the animation looped during the last advance.True if the animation looped, false otherwise.
Animation Information
name
Returns the name of the animation.The animation’s name as defined in the Rive file.
fps
Returns the frames per second of the animation.The animation’s FPS value.
workStart
Returns the work start frame of the animation.The frame number where the animation’s work area starts.
workEnd
Returns the work end frame of the animation.The frame number where the animation’s work area ends.
duration
Returns the total duration of the animation in frames.The animation’s duration in frames.
effectiveDuration
Returns the effective duration of the animation in frames (accounting for work area).The effective duration in frames.
effectiveDurationInSeconds
Returns the effective duration of the animation in seconds.The effective duration in seconds.
Playback State
hasEnded
Returns whether the animation has ended.True if the animation has finished playing, false otherwise.