public class PActivity extends Object
See the PNode.animate*() methods for an example of how to set up and run different activities.
Modifier and Type | Class and Description |
---|---|
static interface |
PActivity.PActivityDelegate
PActivityDelegate is used by classes to learn about and act on the
different states that a PActivity goes through, such as when the activity
starts and stops stepping.
|
Modifier and Type | Field and Description |
---|---|
static int |
TERMINATE_AND_FINISH
Parameter for terminate that signifies that activity should bail out
immediately, but flag activity as finished.
|
static int |
TERMINATE_AND_FINISH_IF_STEPPING
Parameter for terminate that signifies that activity should bail out
immediately, if currently active.
|
static int |
TERMINATE_WITHOUT_FINISHING
Parameter for terminate that signifies that activity should bail out
immediately without flagging activity as finished.
|
Constructor and Description |
---|
PActivity(long aDuration)
Constructs a new PActivity.
|
PActivity(long aDuration,
long aStepRate)
Constructs a new PActivity.
|
PActivity(long aDuration,
long aStepRate,
long aStartTime)
Constructs a new PActivity.
|
Modifier and Type | Method and Description |
---|---|
protected void |
activityFinished()
This method is called after an activity is has finished running and the
activity has been removed from the PActivityScheduler queue.
|
protected void |
activityStarted()
This method is called right before an activity is scheduled to start
running.
|
protected void |
activityStep(long elapsedTime)
This is the method that most activities override to perform their
behavior.
|
PActivityScheduler |
getActivityScheduler()
Returns the activity scheduler associated with this activity.
|
PActivity.PActivityDelegate |
getDelegate()
Get the delegate for this activity.
|
long |
getDuration()
Return the amount of time that this activity should take to complete,
after the startStepping method is called.
|
long |
getNextStepTime()
Gets the next step time desired for this activity.
|
long |
getStartTime()
Return the time that this activity should start running in PRoot global
time.
|
long |
getStepRate()
Return the amount of time that this activity should delay between steps.
|
long |
getStopTime()
Return the time when this activity should finish running.
|
protected boolean |
isAnimation()
Return true if this activity is performing an animation.
|
boolean |
isStepping()
Return true if this activity is stepping.
|
long |
processStep(long currentTime)
The activity scheduler calls this method and it is here that the activity
decides if it should do a step or not for the given time.
|
void |
setActivityScheduler(PActivityScheduler aScheduler)
Informs the activity of the scheduler that will be responsible for
scheduling it.
|
void |
setDelegate(PActivity.PActivityDelegate delegate)
Set the delegate for this activity.
|
void |
setDuration(long aDuration)
Set the amount of time that this activity should take to complete, after
the startStepping method is called.
|
void |
setStartTime(long aTriggerTime)
Set the time that this activity should start running in PRoot global
time.
|
void |
setStepRate(long aStepRate)
Set the amount of time that this activity should delay between steps.
|
void |
startAfter(PActivity first)
Schedules this activity to start after the first activity has finished.
|
void |
terminate()
Stop this activity immediately, and remove it from the activity
scheduler.
|
void |
terminate(int terminationBehavior)
Stop this activity immediately, and remove it from the activity
scheduler.
|
public static final int TERMINATE_WITHOUT_FINISHING
public static final int TERMINATE_AND_FINISH
public static final int TERMINATE_AND_FINISH_IF_STEPPING
public PActivity(long aDuration)
aDuration
- the amount of time that this activity should take to
complete, -1 for infinite.public PActivity(long aDuration, long aStepRate)
aDuration
- the amount of time that this activity should take to
complete, -1 for infinite.aStepRate
- the maximum rate that this activity should receive step
events.public PActivity(long aDuration, long aStepRate, long aStartTime)
aDuration
- the amount of time that this activity should take to
complete, -1 for infinite.aStepRate
- the maximum rate that this activity should receive step
events.aStartTime
- the time (relative to System.currentTimeMillis()) that
this activity should start.public long getStartTime()
public void setStartTime(long aTriggerTime)
aTriggerTime
- time at which you want this activity to begin in
PRoot global timepublic long getStepRate()
public void setStepRate(long aStepRate)
aStepRate
- desired step rate in milliseconds between stepspublic long getNextStepTime()
public long getDuration()
public void setDuration(long aDuration)
aDuration
- desired duration this activity should take (-1 for
infinite) once it begins steppingpublic PActivityScheduler getActivityScheduler()
public void setActivityScheduler(PActivityScheduler aScheduler)
aScheduler
- scheduler to associate with this activitypublic boolean isStepping()
protected boolean isAnimation()
protected void activityStarted()
protected void activityStep(long elapsedTime)
elapsedTime
- the amount of time that has passed relative to the
activities startTime.protected void activityFinished()
public PActivity.PActivityDelegate getDelegate()
public void setDelegate(PActivity.PActivityDelegate delegate)
delegate
- delegate that should be informed of activity eventspublic void startAfter(PActivity first)
first
- activity after which this activity should be scheduledpublic void terminate()
public void terminate(int terminationBehavior)
terminationBehavior
- behavior to use regarding delegate
notification and event firingpublic long processStep(long currentTime)
currentTime
- in global root timepublic long getStopTime()
Copyright © 1995-2013 Piccolo2D. All Rights Reserved.