public class PInterpolatingActivity extends PActivity
The mode determines how the activity interpolates between the two states. The default mode interpolates from source to destination, but you can also go from destination to source, and from source to destination to source.
A loopCount of greater then one will make the activity reschedule itself when it has finished. This makes the activity loop between the two states.
PActivity.PActivityDelegate
Modifier and Type | Field and Description |
---|---|
static int |
DESTINATION_TO_SOURCE
Specifies that interpolation will be from the destination value to the
source value.
|
static int |
SOURCE_TO_DESTINATION
Specifies that interpolation will be from the source value to the
destination value.
|
static int |
SOURCE_TO_DESTINATION_TO_SOURCE
Specifies that interpolation proceed from the source to the destination
then back to the source.
|
TERMINATE_AND_FINISH, TERMINATE_AND_FINISH_IF_STEPPING, TERMINATE_WITHOUT_FINISHING
Constructor and Description |
---|
PInterpolatingActivity(long duration)
Constructs an interpolating activity that will last the duration given.
|
PInterpolatingActivity(long duration,
long stepRate)
Constructs an interpolating activity that will last the duration given
and will update its target at the given rate.
|
PInterpolatingActivity(long duration,
long stepRate,
int loopCount,
int mode)
Constructs an interpolating activity that will last the duration given
and will update its target at the given rate.
|
PInterpolatingActivity(long duration,
long stepRate,
long startTime,
int loopCount,
int mode)
Create a new PInterpolatingActivity.
|
Modifier and Type | Method and Description |
---|---|
protected void |
activityFinished()
Called whenever the activity finishes.
|
protected void |
activityStarted()
Called when activity is started.
|
protected void |
activityStep(long elapsedTime)
Called at each step of the activity.
|
float |
computeSlowInSlowOut(float zeroToOne)
Computes percent or linear interpolation to apply when taking
acceleration into account.
|
boolean |
getFirstLoop()
Return true if the activity is executing its first loop.
|
int |
getLoopCount()
Return the number of times the activity should automatically reschedule
itself after it has finished.
|
int |
getMode()
Return the mode used for interpolation.
|
boolean |
getSlowInSlowOut()
Returns whether this interpolation accelerates and then decelerates as it
interpolates.
|
void |
setDuration(long duration)
Set the amount of time that this activity should take to complete, after
the startStepping method is called.
|
void |
setFirstLoop(boolean firstLoop)
Set if the activity is executing its first loop.
|
void |
setLoopCount(int loopCount)
Set the number of times the activity should automatically reschedule
itself after it has finished.
|
void |
setMode(int mode)
Set the direction in which interpolation is going to occur.
|
void |
setRelativeTargetValue(float zeroToOne)
Subclasses should override this method and set the value on their target
(the object that they are modifying) accordingly.
|
protected void |
setRelativeTargetValueAdjustingForMode(float zeroToOne)
Assigns relative target value taking the mode into account.
|
void |
setSlowInSlowOut(boolean isSlowInSlowOut)
Sets whether this interpolation accelerates and then decelerates as it
interpolates.
|
void |
terminate()
Stop this activity immediately, and remove it from the activity
scheduler.
|
getActivityScheduler, getDelegate, getDuration, getNextStepTime, getStartTime, getStepRate, getStopTime, isAnimation, isStepping, processStep, setActivityScheduler, setDelegate, setStartTime, setStepRate, startAfter, terminate
public static final int SOURCE_TO_DESTINATION
public static final int DESTINATION_TO_SOURCE
public static final int SOURCE_TO_DESTINATION_TO_SOURCE
public PInterpolatingActivity(long duration)
duration
- duration in milliseconds of the entire activitypublic PInterpolatingActivity(long duration, long stepRate)
duration
- duration in milliseconds of the entire activitystepRate
- interval in milliseconds between updates to targetpublic PInterpolatingActivity(long duration, long stepRate, int loopCount, int mode)
duration
- duration in milliseconds of the entire activitystepRate
- interval in milliseconds between updates to targetloopCount
- # of times to repeat this activity.mode
- controls the direction of the interpolation (source to
destination, destination to source, or source to destination
back to source)public PInterpolatingActivity(long duration, long stepRate, long startTime, int loopCount, int mode)
duration
- the length of one loop of the activitystepRate
- the amount of time between steps of the activitystartTime
- the time (relative to System.currentTimeMillis()) that
this activity should start. This value can be in the future.loopCount
- number of times the activity should reschedule itselfmode
- defines how the activity interpolates between statespublic void setDuration(long duration)
setDuration
in class PActivity
duration
- new duration of this activitypublic int getMode()
public void setMode(int mode)
mode
- the new mode to use when interpolatingpublic int getLoopCount()
public void setLoopCount(int loopCount)
loopCount
- number of times to repeat this activitypublic boolean getFirstLoop()
public void setFirstLoop(boolean firstLoop)
firstLoop
- true if executing first looppublic boolean getSlowInSlowOut()
public void setSlowInSlowOut(boolean isSlowInSlowOut)
isSlowInSlowOut
- true if this interpolation inovolves some
accelerationsprotected void activityStarted()
activityStarted
in class PActivity
protected void activityStep(long elapsedTime)
activityStep
in class PActivity
elapsedTime
- number of milliseconds since the activity beganprotected void activityFinished()
activityFinished
in class PActivity
public void terminate()
public void setRelativeTargetValue(float zeroToOne)
zeroToOne
- relative completion of task.public float computeSlowInSlowOut(float zeroToOne)
zeroToOne
- Percentage of activity completedprotected void setRelativeTargetValueAdjustingForMode(float zeroToOne)
zeroToOne
- Percentage of activity completedCopyright © 1995-2013 Piccolo2D. All Rights Reserved.