Class While<A extends Actor>

  • All Implemented Interfaces:
    Action<A>

    public final class While<A extends Actor>
    extends java.lang.Object
    implements Action<A>
    Executes action repeatedly while the predicate is true. When the predicate changes from true to false, the currently executed action continues until it finishes and then the While action finishes as well. It will not be executed again even if the predicate becomes true again.

    The constructor expects either a predicate that accepts While action as a parameter, or a parameter-less predicate.

    • Constructor Summary

      Constructors 
      Constructor Description
      While​(@NotNull java.util.function.Predicate<? super While<A>> predicate, @NotNull Action<A> action)  
      While​(@NotNull java.util.function.Supplier<java.lang.Boolean> simplePredicate, @NotNull Action<A> action)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void execute​(float deltaTime)
      Executes (one step of) the action.
      A getActor()  
      boolean isDone()  
      void reset()
      Resets the state of the action, except the assigned actor.
      void setActor​(A actor)
      Sets actor for the action
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • While

        public While​(@NotNull
                     @NotNull java.util.function.Predicate<? super While<A>> predicate,
                     @NotNull
                     @NotNull Action<A> action)
      • While

        public While​(@NotNull
                     @NotNull java.util.function.Supplier<java.lang.Boolean> simplePredicate,
                     @NotNull
                     @NotNull Action<A> action)
    • Method Detail

      • getActor

        @Nullable
        public A getActor()
        Specified by:
        getActor in interface Action<A extends Actor>
        Returns:
        actor that performs the action
      • setActor

        public void setActor​(@Nullable
                             A actor)
        Description copied from interface: Action
        Sets actor for the action
        Specified by:
        setActor in interface Action<A extends Actor>
        Parameters:
        actor - actor to be set for action
      • isDone

        public boolean isDone()
        Specified by:
        isDone in interface Action<A extends Actor>
        Returns:
        true if the action is done, false otherwise
      • execute

        public void execute​(float deltaTime)
        Description copied from interface: Action
        Executes (one step of) the action. Called by the scene this action was scheduled on, prior to rendering.
        Specified by:
        execute in interface Action<A extends Actor>
        Parameters:
        deltaTime - time passed from the previous execution
      • reset

        public void reset()
        Description copied from interface: Action
        Resets the state of the action, except the assigned actor.
        Specified by:
        reset in interface Action<A extends Actor>