public abstract class Action extends java.lang.Object implements Pool.Poolable
Actor
and perform some task, often over time.Modifier and Type | Field and Description |
---|---|
protected Actor |
actor
The actor this action is attached to, or null if it is not attached.
|
protected Actor |
target
The actor this action targets, or null if a target has not been set.
|
Constructor and Description |
---|
Action() |
Modifier and Type | Method and Description |
---|---|
abstract boolean |
act(float delta)
Updates the action based on time.
|
Actor |
getActor() |
Pool |
getPool() |
Actor |
getTarget() |
void |
reset()
Resets the optional state of this action to as if it were newly created, allowing the action to be pooled and reused.
|
void |
restart()
Sets the state of the action so it can be run again.
|
void |
setActor(Actor actor)
Sets the actor this action is attached to.
|
void |
setPool(Pool pool)
Sets the pool that the action will be returned to when removed from the actor.
|
void |
setTarget(Actor target)
Sets the actor this action will manipulate.
|
java.lang.String |
toString() |
protected Actor actor
protected Actor target
public abstract boolean act(float delta)
Actor.act(float)
.delta
- Time in seconds since the last frame.public void restart()
public void setActor(Actor actor)
target
actor if it is null. This
method is called automatically when an action is added to an actor. This method is also called with null when an action is
removed from an actor.
When set to null, if the action has a pool
then the action is returned
to
the pool (which calls reset()
) and the pool is set to null. If the action does not have a pool, reset()
is
not called.
This method is not typically a good place for an action subclass to query the actor's state because the action may not be
executed for some time, eg it may be delayed
. The actor's state is best queried in the first call to
act(float)
. For a TemporalAction
, use TemporalAction#begin().
public Actor getActor()
public void setTarget(Actor target)
setActor(Actor)
will set the target actor
when the action is added to an actor.public Actor getTarget()
public void reset()
The default implementation calls restart()
.
If a subclass has optional state, it must override this method, call super, and reset the optional state.
reset
in interface Pool.Poolable
public void setPool(@Null Pool pool)
pool
- May be null.setActor(Actor)
public java.lang.String toString()
toString
in class java.lang.Object