Class EntityAnimationController<T extends IEntity>

java.lang.Object
de.gurkenlabs.litiengine.graphics.animation.AnimationController
de.gurkenlabs.litiengine.graphics.animation.EntityAnimationController<T>
All Implemented Interfaces:
IEntityController, IAnimationController, IEntityAnimationController<T>, IUpdateable
Direct Known Subclasses:
CreatureAnimationController, PropAnimationController

public class EntityAnimationController<T extends IEntity>
extends AnimationController
implements IEntityAnimationController<T>
  • Constructor Details

    • EntityAnimationController

      public EntityAnimationController​(T entity)
      Initializes a new instance of the EntityAnimationController class.
      Parameters:
      entity - The entity related to this animation controller.
      See Also:
      getEntity()
    • EntityAnimationController

      public EntityAnimationController​(T entity, Animation defaultAnimation, Animation... animations)
      Initializes a new instance of the EntityAnimationController class.
      Parameters:
      entity - The entity related to this animation controller.
      defaultAnimation - The default animation for this controller.
      animations - Additional animations that are managed by this controller instance.
      See Also:
      getEntity(), AnimationController.getDefault(), AnimationController.getAll()
    • EntityAnimationController

      public EntityAnimationController​(T entity, Spritesheet sprite)
      Initializes a new instance of the EntityAnimationController class.
      Parameters:
      entity - The entity related to this animation controller.
      sprite - The sprite sheet used by the default animation of this controller.
    • EntityAnimationController

      public EntityAnimationController​(T entity, Spritesheet sprite, boolean loop)
      Initializes a new instance of the EntityAnimationController class.
      Parameters:
      entity - The entity related to this animation controller.
      sprite - The sprite sheet used by the default animation of this controller.
      loop - A flag indicating whether the default animation should be looped or only played once.
  • Method Details

    • getDefaultSpritePrefixes

      public static java.lang.String[] getDefaultSpritePrefixes​(java.lang.Class<?> cls)
    • addRule

      public void addRule​(java.util.function.Predicate<? super T> rule, java.util.function.Function<? super T,​java.lang.String> animationName, int priority)
      Description copied from interface: IEntityAnimationController
      Registers an animation rule that will be evaluated if there is currently no animation playing that is defined to loop. This allows to specify animations that should be applied under certain conditions.
      Specified by:
      addRule in interface IEntityAnimationController<T extends IEntity>
      Parameters:
      rule - The rule that must be fulfilled for the animation to be applied
      animationName - The callback that evaluates the actual animation name that will be applied
      priority - The priority that defines the order in which the rule will be processed. Rules with higher priorities will be processed first.
    • addRule

      public void addRule​(java.util.function.Predicate<? super T> rule, java.util.function.Function<? super T,​java.lang.String> animationName)
      Description copied from interface: IEntityAnimationController
      Registers an animation rule that will be evaluated if there is currently no animation playing that is defined to loop. This allows to specify animations that should be applied under certain conditions.
      Specified by:
      addRule in interface IEntityAnimationController<T extends IEntity>
      Parameters:
      rule - The rule that must be fulfilled for the animation to be applied
      animationName - The callback that evaluates the actual animation name that will be applied
    • getEntity

      public T getEntity()
      Specified by:
      getEntity in interface IEntityController
    • update

      public void update()
      Description copied from interface: IUpdateable
      This method is called by the game loop on all objects that are attached to the loop. It's called on every tick of the loop and the frequency can be configured using the ClientConfiguration.
      Specified by:
      update in interface IUpdateable
      Overrides:
      update in class AnimationController
      See Also:
      ClientConfiguration.setMaxFps(int)
    • getSpritePrefix

      protected java.lang.String getSpritePrefix()
    • setSpritePrefix

      protected void setSpritePrefix​(java.lang.String prefix)
    • isAutoScaling

      public boolean isAutoScaling()
      Description copied from interface: IEntityAnimationController
      Gets a flag indicating whether this controller instance is auto scaling its animations by the dimensions of the entity.
      Specified by:
      isAutoScaling in interface IEntityAnimationController<T extends IEntity>
      Returns:
      True if this instance is automatically scaling to the dimensions of the entity; otherwise false.
    • setAutoScaling

      public void setAutoScaling​(boolean scaling)
      Description copied from interface: IEntityAnimationController
      Sets a value indicating whether this controller instance is auto scaling its animations by the dimensions of the entity
      Specified by:
      setAutoScaling in interface IEntityAnimationController<T extends IEntity>
      Parameters:
      scaling - True if this instance is automatically scaling to the dimensions of the entity; otherwise false.
    • scaleSprite

      public void scaleSprite​(float scaleX, float scaleY)
      Description copied from interface: IEntityAnimationController
      Sets the dimensions used to scale the animations of this controller instance.
      Specified by:
      scaleSprite in interface IEntityAnimationController<T extends IEntity>
      Parameters:
      scaleX - The x-ratio to scale the animation with.
      scaleY - The y-ratio to scale the animation with.
    • scaleSprite

      public void scaleSprite​(float scale)
      Description copied from interface: IEntityAnimationController
      Sets the ratio used to scale the animations of this controller instance.
      Specified by:
      scaleSprite in interface IEntityAnimationController<T extends IEntity>
      Parameters:
      scale - The ratio to scale the animation with.