APIdia Launch Partner
Top Description Fields Constructors Methods
com.badlogic.gdx.scenes.scene2d

public abstract Class Action

extends Object
implements Poolable
Class Inheritance
All Implemented Interfaces
com.badlogic.gdx.utils.Pool.Poolable
Known Direct Subclasses
com.badlogic.gdx.scenes.scene2d.actions.AddAction, com.badlogic.gdx.scenes.scene2d.actions.AddListenerAction, com.badlogic.gdx.scenes.scene2d.actions.DelegateAction, com.badlogic.gdx.scenes.scene2d.actions.EventAction, com.badlogic.gdx.scenes.scene2d.actions.LayoutAction, com.badlogic.gdx.scenes.scene2d.actions.ParallelAction, com.badlogic.gdx.scenes.scene2d.actions.RemoveAction, com.badlogic.gdx.scenes.scene2d.actions.RemoveActorAction, com.badlogic.gdx.scenes.scene2d.actions.RemoveListenerAction, com.badlogic.gdx.scenes.scene2d.actions.RunnableAction, com.badlogic.gdx.scenes.scene2d.actions.TemporalAction, com.badlogic.gdx.scenes.scene2d.actions.TouchableAction, com.badlogic.gdx.scenes.scene2d.actions.VisibleAction
Imports
com.badlogic.gdx.scenes.scene2d.actions.DelayAction, .TemporalAction, com.badlogic.gdx.utils.Null, .Pool, .Pool.Poolable

Actions attach to an Actor and perform some task, often over time.
Author
Nathan Sweet

Field Summary

Modifier and TypeField and Description
protected Actor
actor

The actor this action is attached to, or null if it is not attached.

private Pool<T>
protected Actor
target

The actor this action targets, or null if a target has not been set.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public abstract boolean

Returns:

true if the action is done. This method may continue to be called after the action is done.
act
(float
Time in seconds since the last frame.
delta
)

Updates the action based on time.

public Actor
getActor()

Returns: null if the action is not attached to an actor.

public Pool<T>
public Actor
getTarget()

Returns: null if the action has no target.

public void
reset()

Implements com.badlogic.gdx.utils.Pool.Poolable.reset.

Resets the optional state of this action to as if it were newly created, allowing the action to be pooled and reused.

public void
restart()

Sets the state of the action so it can be run again.

public void
setActor(Actor actor)

Sets the actor this action is attached to.

public void
setPool(Pool<T>
May be null.
pool
)

Sets the pool that the action will be returned to when removed from the actor.

public void
setTarget(Actor target)

Sets the actor this action will manipulate.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

actorback to summary
protected Actor actor

The actor this action is attached to, or null if it is not attached.

poolback to summary
private Pool<T> pool
Annotations
@Null
targetback to summary
protected Actor target

The actor this action targets, or null if a target has not been set.

Constructor Detail

Actionback to summary
public Action()

Method Detail

actback to summary
public abstract boolean act(float delta)

Updates the action based on time. Typically this is called each frame by Actor#act(float).

Parameters
delta:float

Time in seconds since the last frame.

Returns:boolean

true if the action is done. This method may continue to be called after the action is done.

getActorback to summary
public Actor getActor()
Returns:Actor

null if the action is not attached to an actor.

getPoolback to summary
public Pool<T> getPool()
Annotations
@Null
getTargetback to summary
public Actor getTarget()
Returns:Actor

null if the action has no target.

resetback to summary
public void reset()

Implements com.badlogic.gdx.utils.Pool.Poolable.reset.

Resets the optional state of this action to as if it were newly created, allowing the action to be pooled and reused. State required to be set for every usage of this action or computed during the action does not need to be reset.

The default implementation calls restart().

If a subclass has optional state, it must override this method, call super, and reset the optional state.

restartback to summary
public void restart()

Sets the state of the action so it can be run again.

setActorback to summary
public void setActor(Actor actor)

Sets the actor this action is attached to. This also sets the 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().

setPoolback to summary
public void setPool(Pool<T> pool)

Sets the pool that the action will be returned to when removed from the actor.

Parameters
pool:Pool<T>

May be null.

See Also
setActor(Actor)
setTargetback to summary
public void setTarget(Actor target)

Sets the actor this action will manipulate. If no target actor is set, setActor(Actor) will set the target actor when the action is added to an actor.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.