Class Director<C>
java.lang.Object
com.github.yellowstonegames.smooth.Director<C>
- Type Parameters:
C- a type that contains or is otherwise associated with aGlider, such as aCoordGlider
Handles multiple objects that are each associated with a
Glider, and allows starting and stopping the
gliding animation for all of those objects at once. This must be given a ObjToObjFunction that can extract some form of
Glider out of a C object; this is typically a method reference, such as to a getter. A Director has an Iterable
of C objects, often an ObjectList or perhaps the Values collection of an
ObjectObjectMap, that it will go through and update the Glider in each C.
User code typically calls step() every frame; this is a no-op if the Director is not playing. If the
Director is playing, then step() calculates the amount of the glide animation that has been completed, loops over
each C in the Iterable, extracts a Glider from each C, calls Glider.setChange(float) on those
Gliders with the calculated amount, and potentially calls stop() if the animation has completed. You get the
Director playing with play(), and can pause it temporarily with pause() (you resume a paused
Director with play() again), or stop the Director entirely with stop() (which sets it back to the beginning
of the animation).-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlongGets the duration of each glide animation, in milliseconds.booleanvoidpause()voidplay()voidsetContainer(Iterable<C> container) voidsetDuration(long duration) Sets the duration of each glide, in milliseconds, and if the duration changed, callsstop().voidstep()voidstop()
-
Field Details
-
extractor
-
container
-
playTime
protected long playTime -
playing
protected boolean playing -
duration
protected long duration -
elapsed
protected long elapsed
-
-
Constructor Details
-
Director
-
Director
-
Director
-
-
Method Details
-
play
public void play() -
pause
public void pause() -
stop
public void stop() -
step
public void step() -
isPlaying
public boolean isPlaying() -
getDuration
public long getDuration()Gets the duration of each glide animation, in milliseconds. The default duration is 500 ms if unspecified.- Returns:
- the duration of each glide, in milliseconds.
-
setDuration
public void setDuration(long duration) Sets the duration of each glide, in milliseconds, and if the duration changed, callsstop(). The default duration is 500 ms if unspecified.- Parameters:
duration- how long each glide animation should take, in milliseconds
-
getContainer
-
setContainer
-