Class 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 ActionManager that 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.

    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected Action​(java.util.function.Predicate<Action> terminator)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Action chain​(Action next)
      Chains another action that should be performed immediately after this action has been completed.
      static Action indefinitely()
      Creates an action that will remain active indefinitely.
      boolean isActive()  
      boolean isCompleted()  
      Action onCompleted​(java.lang.Runnable callback)  
      Action onFrame​(java.lang.Runnable callback)  
      Action onFrame​(java.util.function.Consumer<java.lang.Float> callback)  
      Action onStart​(java.lang.Runnable callback)  
      static Action timed​(float duration)
      Creates an action that will remain active for a limited amount of time
      static Action until​(java.util.function.Predicate<Action> terminator)
      Creates an action that will remain active until the specified condition starts to return true.
      void update​(float deltaTime)
      Updates this object for the current frame.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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: Updatable
        Updates this object for the current frame.
        Specified by:
        update in interface Updatable
        Parameters:
        deltaTime - Elapsed time since the last frame, in seconds.
      • 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.
      • until

        public static Action until​(java.util.function.Predicate<Action> terminator)
        Creates an action that will remain active until the specified condition starts to return true.