Class Effect

java.lang.Object
nl.colorize.multimedialib.scene.effect.Effect
All Implemented Interfaces:
Scene

@Deprecated public final class Effect extends Object implements Scene
Deprecated.
This class is a combination of graphics and logic. The former is best handled in application code, the latter is best handled by the various convenience methods to create sub-scenes in SceneContext. This class will be removed in a future version of MultimediaLib.
Effects are short-lived sub-scenes that can be defined in a declarative style. Effects are not intended to contain general application logic, they are intended for small, self-contained effects that are active for a limited period of time and are independent of other things happening in the scene.

Behavior can be added to effects in the form of handlers. These handlers operate on different points in the effect's lifecycle, for example during frame updates or after the effect is marked as completed.

Effects can be "linked" to graphics. When the effect ends, it will automatically remove all linked graphics from the stage. This allows the effect to control the life cycle for both the effect logic and the associated graphics.

  • Constructor Details

    • Effect

      public Effect()
      Deprecated.
      Creates a new effect that initially does not define any behavior and is not linked to any graphics. Prefer using the static factory methods to create effects with the desired behavior.
  • Method Details

    • addFrameHandler

      public Effect addFrameHandler(Updatable handler)
      Deprecated.
    • addFrameHandler

      public Effect addFrameHandler(Runnable handler)
      Deprecated.
    • addTimerHandler

      public Effect addTimerHandler(Timer timer, Consumer<Float> callback)
      Deprecated.
      Adds a frame handler that will update the specified timer during every update, then invokes the callback function based on the timer's new value. This effect will be marked as completed once the timer ends.
    • addTimelineHandler

      public Effect addTimelineHandler(nl.colorize.util.animation.Timeline timeline, Consumer<Float> callback)
      Deprecated.
      Adds a frame handler that will update the specified timeline during every frame update, then invokes the callback function based on the timeline's new value. The effect will be marked as completed once the timeline ends.
    • addClickHandler

      public Effect addClickHandler(Rect bounds, Runnable handler)
      Deprecated.
    • addClickHandler

      public Effect addClickHandler(Supplier<Rect> bounds, Runnable handler)
      Deprecated.
    • addClickHandler

      public Effect addClickHandler(StageNode2D graphic, Runnable handler)
      Deprecated.
    • addCompletionHandler

      public Effect addCompletionHandler(Runnable handler)
      Deprecated.
    • stopAfter

      public Effect stopAfter(float duration)
      Deprecated.
      Adds a handler that will mark the effect as completed once the specified period of time has elapsed.
    • stopAfterAnimation

      public Effect stopAfterAnimation(Sprite sprite)
      Deprecated.
      Adds a handler that will mark the effect as completed once the specified sprite animation has ended.
    • stopIf

      public Effect stopIf(BooleanSupplier condition)
      Deprecated.
      Adds a handler that will mark the effect as completed once the specified condition is met.
    • stopNow

      public Effect stopNow()
      Deprecated.
      Adds a handler that will mark the effect as completed during the next frame update.
    • stopNever

      public Effect stopNever()
      Deprecated.
      Adds a handler that will always return false, and will therefore make the effect continue indefinitely.
    • linkGraphics

      public Effect linkGraphics(StageNode2D... graphics)
      Deprecated.
      Links existing graphics to this effect. This means the graphics will be removed from stage when the effect has completed.
    • removeAfterwards

      @Deprecated public Effect removeAfterwards(StageNode2D... graphics)
      Deprecated.
      Links existing graphics to this effect. This means the graphics will be removed from stage when the effect has completed.
    • update

      public void update(SceneContext context, float deltaTime)
      Deprecated.
      Description copied from interface: Scene
      Called during every frame update for as long as the scene is active. deltaTime indicates the elapsed time since the last frame, in seconds.
      Specified by:
      update in interface Scene
    • end

      public void end(SceneContext context)
      Deprecated.
      Description copied from interface: Scene
      Clean-up logic that is performed every time the scene ends.

      This method is optional, the default implementation does nothing.

      Specified by:
      end in interface Scene
    • isCompleted

      public boolean isCompleted()
      Deprecated.
      Description copied from interface: Scene
      Indicates the scene has been completed and no longer wishes to receive frame updates.

      If this scene is the currently active scene, it might not actually end until a new scene is requested.

      If this scene is a completed sub-scene, meaning there is a parent scene which is still active, this sub-scene will end after the current frame.

      Specified by:
      isCompleted in interface Scene
    • withLinkedGraphics

      @Deprecated public void withLinkedGraphics(Consumer<StageNode2D> callback)
      Deprecated.
    • withLinkedGraphics

      @Deprecated public <T extends StageNode2D> void withLinkedGraphics(Class<T> type, Consumer<T> callback)
      Deprecated.
    • attach

      public Effect attach(SceneContext context)
      Deprecated.
      Attaches this effect to the specified scene context. Using this method is identical to sceneContext.attach(effect), but is more readable when creating effects using the fluent API.
    • delay

      public static Effect delay(float duration, Runnable action)
      Deprecated.
      Creates an effect that will first wait for the specified period of time, and will then perform an action.