Skip to content

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.

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.

ReturnsSignatureSummary
TweenAnimatorcreate() factoryCreates an animator whose value is 0F, without timeline.
TweenAnimatorcreate(float value) factoryCreates an animator whose value is value, without timeline.

PropertyTypeDefaultSummary
timelineTimelinenullThe timeline that moves the value, or null when none is playing.
speedfloat1FThe factor applied to the elapsed time: 2F plays twice as fast, 0.5F half as fast, 0F freezes the animation.

ReturnsSignatureSummary
thisupdate() fluentAdvances the timeline by the time elapsed since the start or the previous update, and stops the advance once per frame, then returns this animator.
thisupdate(float delta) fluentAdvances the timeline by delta ms, multiplied by the speed, and stops the advance once per frame, then returns this animator.
ReturnsSignatureSummary
booleanisWritable()Returns false: only the timeline, value(...) and clear() change the value.
booleanisAutomatic()If true, JOID advances the animator once per frame: from start() until the timeline ends, clear(), value(...), sequence(...) or update(...).
ReturnsSignatureSummary
thisstart() fluentStarts the timeline from its beginning and lets JOID advance it once per frame, then returns this animator.
TweenAnimatorcopy()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.
thisremoveOnChange(SignalListener<? super Float> listener) fluentRemoves a listener given to onChange(...), then returns this animator.
thissequence(float duration, float value) fluentKills the current timeline and creates a sequence whose first step goes to value in duration ms, with a linear easing, then returns this animator.
thissequence(float duration, float value, TweenEquation easing) fluentKills the current timeline and creates a sequence whose first step goes to value in duration ms with easing, then returns this animator.
thisdelay(float delay) fluentAdds delay ms of waiting before the timeline starts, then returns this animator.
thisrepeat(int count, float delay) fluentPlays the timeline count more times after the first, with delay ms between two plays, then returns this animator; BaseTween.INFINITY repeats forever.
thisrepeatYoyo(int count, float delay) fluentRepeats like repeat(...), every other play backward, then returns this animator.
thispush(float duration, float value) fluentAdds a step that goes from the value reached to value in duration ms, with a linear easing, then returns this animator.
thispush(float duration, float value, TweenEquation easing) fluentAdds a step that goes from the value reached to value in duration ms with easing, then returns this animator.
thisvalue(float value) fluentStops the animation, drops the timeline and sets the value, then returns this animator.
thisclear() fluentStops the animation, sets the value to 0F and the speed to 1F, then returns this animator.
Tweentween(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

EventListenerSummary
onChangeSignalListener<? super Float>Adds a listener that runs with the value after each change, on the render thread, then returns this animator.
onStartEventListener<TweenEvent>Adds a listener that runs when the timeline starts playing, after its delay.
onIterationStartEventListener<TweenEvent>Adds a listener that runs at the start of each play of the timeline.
onIterationEndEventListener<TweenEvent>Adds a listener that runs at the end of each play of the timeline.
onCompleteEventListener<TweenEvent>Adds a listener that runs when the last play of the timeline ends; it never runs for a repetition forever.
onReverseStartEventListener<TweenEvent>Adds a listener that runs when the timeline starts playing backward from its end, after an update with a negative time.
onReverseIterationStartEventListener<TweenEvent>Adds a listener that runs at the start of each play backward.
onReverseIterationEndEventListener<TweenEvent>Adds a listener that runs at the end of each play backward.
onReverseCompleteEventListener<TweenEvent>Adds a listener that runs when the timeline played backward reaches its beginning.

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.

  • this timeline(Timeline timeline) fluent
  • Timeline 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) fluent
  • float 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.

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.

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(...).

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.

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. Throws an IllegalStateException once the timeline is started.

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.

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.

this onStart(EventListener<TweenEvent> listener) fluent

Adds a listener that runs when the timeline starts playing, after its delay.

this onIterationStart(EventListener<TweenEvent> listener) fluent

Adds a listener that runs at the start of each play of the timeline.

this onIterationEnd(EventListener<TweenEvent> listener) fluent

Adds a listener that runs at the end of each play of the timeline.

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.

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.

this onReverseIterationStart(EventListener<TweenEvent> listener) fluent

Adds a listener that runs at the start of each play backward.

this onReverseIterationEnd(EventListener<TweenEvent> listener) fluent

Adds a listener that runs at the end of each play backward.

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

Report a problem with this page