Class When<A extends Actor>

  • All Implemented Interfaces:
    Action<A>

    public final class When<A extends Actor>
    extends java.lang.Object
    implements Action<A>
    Executes the given action one time, once the predicate becomes true.

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

    • Constructor Summary

      Constructors 
      Constructor Description
      When​(@NotNull java.util.function.Predicate<? super When<A>> predicate, @NotNull Action<A> action)  
      When​(@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

      • When

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

        public When​(@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>