Package nl.colorize.multimedialib.scene
Class Action
- java.lang.Object
-
- nl.colorize.multimedialib.scene.Action
-
- All Implemented Interfaces:
Updatable
- Direct Known Subclasses:
Effect
public class Action extends java.lang.Object implements Updatable
Logic that is active for a certain amount of time during a scene. Actions can be used to declare scene behavior in a declarative way. Behavior can be added when the action is started, when it completes, for every frame while it is active. Actions can be configured to remain active for a certain amount of time, until a certain condition is reached, or indefinitely for the remainder of the scene.The administration of playing actions is usually handled in combination with a
ActionManagerthat keeps track of all actions that are played during a scene.Actions contain only logic and do not define graphical behavior. Use
Effects to have a similar mechanism for defining graphics that should be shown during the scene.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Actionchain(Action next)Chains another action that should be performed immediately after this action has been completed.static Actionindefinitely()Creates an action that will remain active indefinitely.booleanisActive()booleanisCompleted()ActiononCompleted(java.lang.Runnable callback)ActiononFrame(java.lang.Runnable callback)ActiononFrame(java.util.function.Consumer<java.lang.Float> callback)ActiononStart(java.lang.Runnable callback)static Actiontimed(float duration)Creates an action that will remain active for a limited amount of timestatic Actionuntil(java.util.function.Predicate<Action> terminator)Creates an action that will remain active until the specified condition starts to return true.voidupdate(float deltaTime)Updates this object for the current frame.
-
-
-
Constructor Detail
-
Action
protected Action(java.util.function.Predicate<Action> terminator)
-
-
Method Detail
-
onStart
public Action onStart(java.lang.Runnable callback)
-
onFrame
public Action onFrame(java.util.function.Consumer<java.lang.Float> callback)
-
onFrame
public Action onFrame(java.lang.Runnable callback)
-
onCompleted
public Action onCompleted(java.lang.Runnable callback)
-
chain
public Action chain(Action next)
Chains another action that should be performed immediately after this action has been completed.- Throws:
java.lang.IllegalStateException- if another chained action has already been registered.
-
update
public void update(float deltaTime)
Description copied from interface:UpdatableUpdates this object for the current frame.
-
isCompleted
public boolean isCompleted()
-
isActive
public boolean isActive()
-
indefinitely
public static Action indefinitely()
Creates an action that will remain active indefinitely.
-
timed
public static Action timed(float duration)
Creates an action that will remain active for a limited amount of time- Parameters:
duration- Action duration in seconds.
-
-