Interface IAnimationController

All Superinterfaces:
IUpdateable
All Known Subinterfaces:
IEntityAnimationController<T>
All Known Implementing Classes:
AnimationController, CreatureAnimationController, EntityAnimationController, PropAnimationController

public interface IAnimationController
extends IUpdateable
  • Method Summary

    Modifier and TypeMethodDescription
    voidadd​(Animation animation)
    Add the specified Animation to this controller instance.
    voidadd​(ImageEffect effect)
    Adds the specified ImageEffect to be applied when the current image is retrieved from this controller.
    voidaddListener​(AnimationListener listener)
    Adds the specified animation listener to receive events and callbacks when animation playbacks are started and finished.
    voidclear()
    Remove all Animations from the AnimationController.
    Animationget​(java.lang.String animationName)
    Gets the Animation instance with the specified name from this controller.
    java.awt.geom.AffineTransformgetAffineTransform()
    Gets the AffineTransform instance assigned to this controller that can be used to externally transform the current image when rendering it with the ImageRenderer.
    java.util.Collection<Animation>getAll()
    Gets all Animation instances managed by this controller.
    AnimationgetCurrent()
    Gets the currently active Animation of this controller.
    java.awt.image.BufferedImagegetCurrentImage()
    Gets the current sprite (keyframe) of the currently active animation of this controller.
    java.awt.image.BufferedImagegetCurrentImage​(int width, int height)
    Gets the current sprite scaled by the specified dimensions of the currently active animation of this controller.
    AnimationgetDefault()
    Gets the default Animation of this controller.
    java.util.List<ImageEffect>getImageEffects()
    Gets all image effects assigned to this controller.
    booleanhasAnimation​(java.lang.String animationName)
    Determines whether this controller has an Animation with the specified name.
    booleanisEnabled()
    Determines whether this controller is currently enabled.
    booleanisPlaying​(java.lang.String animationName)
    Determines whether this controller is currently playing an Animation with the specified name.
    voidplay​(java.lang.String animationName)
    Plays the Animation with the specified name.
    voidremove​(Animation animation)
    Removes the specified Animation from this controller instance.
    voidremove​(ImageEffect effect)
    Removes the specified ImageEffect from this controller.
    voidremoveListener​(AnimationListener listener)
    Removes the specified animation listener.
    voidsetAffineTransform​(java.awt.geom.AffineTransform affineTransform)
    Sets the AffineTransform instance for this controller that can be used to externally transform the current image when rendering it with the ImageRenderer.
    voidsetDefault​(Animation animation)
    Sets the specified Animation as default for this controller.
    voidsetEnabled​(boolean enabled)
    Sets a flag that defines whether this controller is enabled or not.

    Methods inherited from interface de.gurkenlabs.litiengine.IUpdateable

    update
  • Method Details

    • addListener

      void addListener​(AnimationListener listener)
      Adds the specified animation listener to receive events and callbacks when animation playbacks are started and finished.
      Parameters:
      listener - The listener to add.
    • removeListener

      void removeListener​(AnimationListener listener)
      Removes the specified animation listener.
      Parameters:
      listener - The listener to remove.
    • add

      void add​(Animation animation)
      Add the specified Animation to this controller instance.

      Animations with the same name will be replaced by this method.

      Parameters:
      animation - The animation to add.
      See Also:
      remove(Animation), hasAnimation(String), clear()
    • remove

      void remove​(Animation animation)
      Removes the specified Animation from this controller instance.
      Parameters:
      animation - The animation to remove.
      See Also:
      add(Animation), hasAnimation(String), clear()
    • clear

      void clear()
      Remove all Animations from the AnimationController.
    • getAll

      java.util.Collection<Animation> getAll()
      Gets all Animation instances managed by this controller.
      Returns:
      All Animation instances.
    • get

      Animation get​(java.lang.String animationName)
      Gets the Animation instance with the specified name from this controller.

      The name of an Animation is case sensitive.

      Parameters:
      animationName - The name of the animation.
      Returns:
      The animation with the specified name or null if no such animation is managed by this controller.
      See Also:
      getCurrent(), getDefault(), hasAnimation(String)
    • getCurrent

      Animation getCurrent()
      Gets the currently active Animation of this controller.

      The current active animation provides the current image that is being rendered by consumers of this controller (e.g. the render engine or any explicit, custom render mechanism).

      Returns:
      The currently active animation.
      See Also:
      getDefault(), get(String), RenderEngine.renderEntity(java.awt.Graphics2D, de.gurkenlabs.litiengine.entities.IEntity)
    • getDefault

      Animation getDefault()
      Gets the default Animation of this controller.

      This animation is played when no other animation is currently active.

      Returns:
      The default animation of this controller.
      See Also:
      getCurrent(), get(String), setDefault(Animation)
    • hasAnimation

      boolean hasAnimation​(java.lang.String animationName)
      Determines whether this controller has an Animation with the specified name.

      The name of an Animation is case sensitive.

      Parameters:
      animationName - The name of the animation.
      Returns:
      True if this controller contains an Animation with the specified name; otherwise false.
      See Also:
      add(Animation), remove(Animation)
    • isPlaying

      boolean isPlaying​(java.lang.String animationName)
      Determines whether this controller is currently playing an Animation with the specified name.

      The name of an Animation is case sensitive.

      Parameters:
      animationName - The name of the animation.
      Returns:
      True if this controller is currently playing the Animation with the specified name.
      See Also:
      getCurrent()
    • play

      void play​(java.lang.String animationName)
      Plays the Animation with the specified name.

      Does nothing if this controller doesn't contain an Animation with the specified name.

      This method also publishes the "played" event to all subscribed AnimationListener instances.

      Parameters:
      animationName - The name of the Animation to be played.
      See Also:
      AnimationListener.played(Animation), getCurrent()
    • setDefault

      void setDefault​(Animation animation)
      Sets the specified Animation as default for this controller.
      Parameters:
      animation - The animation to be set as default.
      See Also:
      getDefault()
    • getCurrentImage

      java.awt.image.BufferedImage getCurrentImage()
      Gets the current sprite (keyframe) of the currently active animation of this controller.

      The implementation of this method applies all registered ImageEffects.

      Returns:
      The current sprite of the current animation with applied effects; or null, if this controller is currently disabled.
      See Also:
      getCurrent(), Animation.getCurrentKeyFrame(), isEnabled()
    • getCurrentImage

      java.awt.image.BufferedImage getCurrentImage​(int width, int height)
      Gets the current sprite scaled by the specified dimensions of the currently active animation of this controller.

      The implementation of this method applies all registered ImageEffects.

      Parameters:
      width - The width of the image.
      height - The height of the image.
      Returns:
      The current sprite of the current animation scaled by the defined dimensions with applied effects; or null, if this controller is currently disabled.
      See Also:
      getCurrent(), getCurrentImage(), Animation.getCurrentKeyFrame(), isEnabled()
    • getAffineTransform

      java.awt.geom.AffineTransform getAffineTransform()
      Gets the AffineTransform instance assigned to this controller that can be used to externally transform the current image when rendering it with the ImageRenderer.
      Returns:
      The AffineTransform instance assigned to this controller or null.
      See Also:
      AffineTransform, ImageRenderer.renderTransformed(java.awt.Graphics2D, java.awt.Image, AffineTransform), setAffineTransform(AffineTransform), getCurrentImage()
    • setAffineTransform

      void setAffineTransform​(java.awt.geom.AffineTransform affineTransform)
      Sets the AffineTransform instance for this controller that can be used to externally transform the current image when rendering it with the ImageRenderer.
      Parameters:
      affineTransform - The AffineTransform instance for this controller.
      See Also:
      AffineTransform, getAffineTransform()
    • add

      void add​(ImageEffect effect)
      Adds the specified ImageEffect to be applied when the current image is retrieved from this controller.
      Parameters:
      effect - The image effect to be added.
    • remove

      void remove​(ImageEffect effect)
      Removes the specified ImageEffect from this controller.
      Parameters:
      effect - The image effect to be removed.
    • getImageEffects

      java.util.List<ImageEffect> getImageEffects()
      Gets all image effects assigned to this controller.
      Returns:
      All image effects of this controller.
      See Also:
      add(ImageEffect), remove(ImageEffect)
    • isEnabled

      boolean isEnabled()
      Determines whether this controller is currently enabled.
      Returns:
      True if this controller is enabled; otherwise false.
    • setEnabled

      void setEnabled​(boolean enabled)
      Sets a flag that defines whether this controller is enabled or not.
      Parameters:
      enabled - True if the controller should be enabled; otherwise false.