|
PulpCore | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object pulpcore.animation.Animation
public abstract class Animation
An Animation changes state over a specific duration. It is up to subclasses to
implement the updateState(int)
method to change the state as the Animation is updated
over time. An Animation is updated over time with its update(int)
method, which is
typically called by a Timeline
or, in the case of a Tween
, by the
Property
it is attached to.
A simple Animation starts immediately:
|===================| 0 duration end ------- time ------->
Animations can delay before they start:
|--------------|===================| 0 startDelay duration end ---------------- time --------------->
Animations can loop:
|--------------|===================|===================|===================| 0 startDelay duration duration duration end ----------------------------------- time ------------------------------------>
Animations can have a delay between loops:
|--------------|================|------|================|------|================| 0 startDelay duration loop duration loop duration end delay delay ------------------------------------- time ------------------------------------->
Also, Animations can have an Easing
to make the Animation look more smooth.
Field Summary | |
---|---|
static int |
LOOP_FOREVER
Value indicating that the Animation loops forever. |
Constructor Summary | |
---|---|
Animation(int duration)
|
|
Animation(int duration,
Easing easing)
|
|
Animation(int duration,
Easing easing,
int startDelay)
|
Method Summary | |
---|---|
void |
fastForward()
Sets the current time to the end of this animation. |
int |
getDuration()
|
Easing |
getEasing()
|
int |
getLoopDelay()
|
int |
getNumLoops()
|
int |
getStartDelay()
|
int |
getTime()
|
int |
getTotalDuration()
Returns the total duration including the start delay and loops. |
boolean |
isFinished()
|
void |
loop(int numLoops)
Sets the number of loops to play. |
void |
loop(int numLoops,
int loopDelay)
Sets the number of loops to play. |
void |
loopForever()
Causes this animation to loop indefinitely. |
void |
loopForever(int loopDelay)
Causes this animation to loop indefinitely. |
void |
rewind()
|
boolean |
update(int elapsedTime)
|
protected abstract void |
updateState(int animTime)
Updates the state based on the animation time, typically from 0 to getDuration() . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int LOOP_FOREVER
loopForever()
,
getTotalDuration()
,
Constant Field ValuesConstructor Detail |
---|
public Animation(int duration)
public Animation(int duration, Easing easing)
public Animation(int duration, Easing easing, int startDelay)
Method Detail |
---|
public final void loopForever()
loop(LOOP_FOREVER, 0)
.
If the duration is 0 this call is ignored.
IllegalArgumentException
- if duration is 0public final void loopForever(int loopDelay)
loop(LOOP_FOREVER, loopDelay)
.
If the duration is 0 and loopDelay is 0, this call is ignored.
loopDelay
- The delay between the end of a duration and the start of a new one.
IllegalArgumentException
- if loopDelay is negative.
IllegalArgumentException
- if duration is 0 and loopDelay is 0.public final void loop(int numLoops)
LOOP_FOREVER
causes this timeline
to play indefinitely.
If looping (numLoops != 1), and the duration is 0, this call is ignored.
numLoops
- The number of times to loop the duration. A value of 1 means the duration
is played exactly once.
IllegalArgumentException
- if numLoops is not LOOP_FOREVER but is < 1.public final void loop(int numLoops, int loopDelay)
LOOP_FOREVER
causes this timeline
to play indefinitely.
If looping (numLoops != 1), and the duration is 0, and loopDelay is 0, this call is ignored.
numLoops
- The number of times to loop the duration. A value of 1 means the duration
is played exactly once.loopDelay
- The delay between the end of one duration and the start of the next one.
IllegalArgumentException
- if numLoops is not LOOP_FOREVER but is < 1.
IllegalArgumentException
- if loopDelay is negative.
IllegalArgumentException
- if looping (numLoops != 1), duration is 0, and loopDelay is 0.public final int getStartDelay()
public final int getDuration()
public final Easing getEasing()
public final int getNumLoops()
public final int getLoopDelay()
public final int getTotalDuration()
public final int getTime()
public final boolean isFinished()
public final void fastForward()
public final void rewind()
public boolean update(int elapsedTime)
protected abstract void updateState(int animTime)
getDuration()
.
Note that the duration can be zero.
animTime
- The animation time, typically from 0 to getDuration()
, although
an Easing
can cause the value to be outside those bounds.
|
PulpCore | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |