TweenAnimator
final class TweenAnimator
Extends: Signal<Float>
Package: dev.joid.lib.animation.animator · Module: core · Source: TweenAnimator.java
Read-only float signal that a timeline of tweens moves over time, the usual way to animate a node.
Description
Section titled “Description”A TweenAnimator is a Signal of a float that you never set: a Timeline of steps moves it, and everything that reads it follows.
Use one for any motion or fade that plays over time: describe the steps with sequence(...) and push(...), then call start().
Read its value like any signal, in a node property, a map(...) or an onChange listener.
Chain, repeat and replay starts one on a click.
Learn more
Section titled “Learn more”Creation
Section titled “Creation”| Returns | Signature | Summary |
|---|---|---|
TweenAnimator | create() factory | Creates an animator whose value is 0F, without timeline. |
TweenAnimator | create(float value) factory | Creates an animator whose value is value, without timeline. |
Properties
Section titled “Properties”| Property | Type | Default | Summary |
|---|---|---|---|
| timeline | Timeline | null | The timeline that moves the value, or null when none is playing. |
| speed | float | 1F | The factor applied to the elapsed time: 2F plays twice as fast, 0.5F half as fast, 0F freezes the animation. |
Methods
Section titled “Methods”Lifecycle
Section titled “Lifecycle”| Returns | Signature | Summary |
|---|---|---|
this | update() fluent | Advances the timeline by the time elapsed since the start or the previous update, and stops the advance once per frame, then returns this animator. |
this | update(float delta) fluent | Advances the timeline by delta ms, multiplied by the speed, and stops the advance once per frame, then returns this animator. |
Queries
Section titled “Queries”| Returns | Signature | Summary |
|---|---|---|
boolean | isWritable() | Returns false: only the timeline, value(...) and clear() change the value. |
boolean | isAutomatic() | If true, JOID advances the animator once per frame: from start() until the timeline ends, clear(), value(...), sequence(...) or update(...). |
Actions
Section titled “Actions”| Returns | Signature | Summary |
|---|---|---|
this | start() fluent | Starts the timeline from its beginning and lets JOID advance it once per frame, then returns this animator. |
TweenAnimator | copy() | Returns a fresh animator with the value, the speed and the listeners of this one, onChange included, without its timeline; the two animators are independent afterwards. |
this | removeOnChange(SignalListener<? super Float> listener) fluent | Removes a listener given to onChange(...), then returns this animator. |
this | sequence(float duration, float value) fluent | Kills the current timeline and creates a sequence whose first step goes to value in duration ms, with a linear easing, then returns this animator. |
this | sequence(float duration, float value, TweenEquation easing) fluent | Kills the current timeline and creates a sequence whose first step goes to value in duration ms with easing, then returns this animator. |
this | delay(float delay) fluent | Adds delay ms of waiting before the timeline starts, then returns this animator. |
this | repeat(int count, float delay) fluent | Plays the timeline count more times after the first, with delay ms between two plays, then returns this animator; BaseTween.INFINITY repeats forever. |
this | repeatYoyo(int count, float delay) fluent | Repeats like repeat(...), every other play backward, then returns this animator. |
this | push(float duration, float value) fluent | Adds a step that goes from the value reached to value in duration ms, with a linear easing, then returns this animator. |
this | push(float duration, float value, TweenEquation easing) fluent | Adds a step that goes from the value reached to value in duration ms with easing, then returns this animator. |
this | value(float value) fluent | Stops the animation, drops the timeline and sets the value, then returns this animator. |
this | clear() fluent | Stops the animation, sets the value to 0F and the speed to 1F, then returns this animator. |
Tween | tween(float duration) | Returns a Tween of duration ms that moves the value of this animator, to place in a Timeline of your own. |
Inherited from Signal (10)
batch · silent · get · peek · isPresent · toString · from · set · reset · map
Events
Section titled “Events”| Event | Listener | Summary |
|---|---|---|
| onChange | SignalListener<? super Float> | Adds a listener that runs with the value after each change, on the render thread, then returns this animator. |
| onStart | EventListener<TweenEvent> | Adds a listener that runs when the timeline starts playing, after its delay. |
| onIterationStart | EventListener<TweenEvent> | Adds a listener that runs at the start of each play of the timeline. |
| onIterationEnd | EventListener<TweenEvent> | Adds a listener that runs at the end of each play of the timeline. |
| onComplete | EventListener<TweenEvent> | Adds a listener that runs when the last play of the timeline ends; it never runs for a repetition forever. |
| onReverseStart | EventListener<TweenEvent> | Adds a listener that runs when the timeline starts playing backward from its end, after an update with a negative time. |
| onReverseIterationStart | EventListener<TweenEvent> | Adds a listener that runs at the start of each play backward. |
| onReverseIterationEnd | EventListener<TweenEvent> | Adds a listener that runs at the end of each play backward. |
| onReverseComplete | EventListener<TweenEvent> | Adds a listener that runs when the timeline played backward reaches its beginning. |
Creation details
Section titled “Creation details”create
Section titled “create”TweenAnimator create() factory
Creates an animator whose value is 0F, without timeline.
TweenAnimator create(float value) factory
Creates an animator whose value is value, without timeline.
Property details
Section titled “Property details”timeline
Section titled “timeline”this timeline(Timeline timeline)fluentTimeline getTimeline()
Default: null
The timeline that moves the value, or null when none is playing.
Setting another timeline kills the current one, and the next update() counts the time from that moment; give a timeline built from tween(...) to drive the animator with nested sequences and parallels.
this speed(float speed)fluentfloat getSpeed()
Default: 1F
The factor applied to the elapsed time: 2F plays twice as fast, 0.5F half as fast, 0F freezes the animation.
clear() sets it back to 1F.
Method details
Section titled “Method details”update
Section titled “update”this update() fluent
Advances the timeline by the time elapsed since the start or the previous update, and stops the advance once per frame, then returns this animator.
this update(float delta) fluent
Advances the timeline by delta ms, multiplied by the speed, and stops the advance once per frame, then returns this animator.
isWritable
Section titled “isWritable”boolean isWritable()
Returns false: only the timeline, value(...) and clear() change the value.
isAutomatic
Section titled “isAutomatic”boolean isAutomatic()
If true, JOID advances the animator once per frame: from start() until the timeline ends, clear(), value(...), sequence(...) or update(...).
this start() fluent
Starts the timeline from its beginning and lets JOID advance it once per frame, then returns this animator.
Throws an IllegalStateException without timeline, or when the timeline is invalid (a block left open, a repetition forever without duration).
TweenAnimator copy()
Returns a fresh animator with the value, the speed and the listeners of this one, onChange included, without its timeline; the two animators are independent afterwards.
removeOnChange
Section titled “removeOnChange”this removeOnChange(SignalListener<? super Float> listener) fluent
Removes a listener given to onChange(...), then returns this animator.
sequence
Section titled “sequence”this sequence(float duration, float value) fluent
Kills the current timeline and creates a sequence whose first step goes to value in duration ms, with a linear easing, then returns this animator.
this sequence(float duration, float value, TweenEquation easing) fluent
Kills the current timeline and creates a sequence whose first step goes to value in duration ms with easing, then returns this animator.
this delay(float delay) fluent
Adds delay ms of waiting before the timeline starts, then returns this animator.
repeat
Section titled “repeat”this repeat(int count, float delay) fluent
Plays the timeline count more times after the first, with delay ms between two plays, then returns this animator; BaseTween.INFINITY repeats forever.
Throws an IllegalStateException once the timeline is started.
repeatYoyo
Section titled “repeatYoyo”this repeatYoyo(int count, float delay) fluent
Repeats like repeat(...), every other play backward, then returns this animator.
this push(float duration, float value) fluent
Adds a step that goes from the value reached to value in duration ms, with a linear easing, then returns this animator.
this push(float duration, float value, TweenEquation easing) fluent
Adds a step that goes from the value reached to value in duration ms with easing, then returns this animator.
this value(float value) fluent
Stops the animation, drops the timeline and sets the value, then returns this animator.
this clear() fluent
Stops the animation, sets the value to 0F and the speed to 1F, then returns this animator.
Tween tween(float duration)
Returns a Tween of duration ms that moves the value of this animator, to place in a Timeline of your own.
Event details
Section titled “Event details”onChange
Section titled “onChange”this onChange(SignalListener<? super Float> listener) fluent
Adds a listener that runs with the value after each change, on the render thread, then returns this animator.
onStart
Section titled “onStart”this onStart(EventListener<TweenEvent> listener) fluent
Adds a listener that runs when the timeline starts playing, after its delay.
onIterationStart
Section titled “onIterationStart”this onIterationStart(EventListener<TweenEvent> listener) fluent
Adds a listener that runs at the start of each play of the timeline.
onIterationEnd
Section titled “onIterationEnd”this onIterationEnd(EventListener<TweenEvent> listener) fluent
Adds a listener that runs at the end of each play of the timeline.
onComplete
Section titled “onComplete”this onComplete(EventListener<TweenEvent> listener) fluent
Adds a listener that runs when the last play of the timeline ends; it never runs for a repetition forever.
onReverseStart
Section titled “onReverseStart”this onReverseStart(EventListener<TweenEvent> listener) fluent
Adds a listener that runs when the timeline starts playing backward from its end, after an update with a negative time.
onReverseIterationStart
Section titled “onReverseIterationStart”this onReverseIterationStart(EventListener<TweenEvent> listener) fluent
Adds a listener that runs at the start of each play backward.
onReverseIterationEnd
Section titled “onReverseIterationEnd”this onReverseIterationEnd(EventListener<TweenEvent> listener) fluent
Adds a listener that runs at the end of each play backward.
onReverseComplete
Section titled “onReverseComplete”this onReverseComplete(EventListener<TweenEvent> listener) fluent
Adds a listener that runs when the timeline played backward reaches its beginning.
fluent returns the instance, typed for chaining · factory creates an instance · signal also accepts a value that follows signals, as a signal, an expression or a lambda (When does JOID compute this value again?) · hook called by JOID, override it · abstract you implement it · default interface method with a body · static called on the class · protected visible to subclasses
