Class CreatureAnimationController<T extends Creature>

Type Parameters:
T - The type of the creature for which animations are managed by this controller.
All Implemented Interfaces:
IEntityController, IAnimationController, IEntityAnimationController<T>, IUpdateable

public class CreatureAnimationController<T extends Creature> extends EntityAnimationController<T>
This AnimationController implementation provides animation rules that use naming conventions to provide Animations for Creature implementations.

The spritesheet images need to be named according to the following conventions in order to be automatically used by this controller:

Where {DIRECTION} refers to a value of the Direction enum and getSpritePrefix() refers to the current sprite prefix of the entity. {EXTENSION} refers to a value of the ImageFormat enum.
See Also:
  • Constructor Details

    • CreatureAnimationController

      public CreatureAnimationController(T creature, boolean useFlippedSpritesAsFallback)
      Initializes a new instance of the CreatureAnimationController class.
      Parameters:
      creature - The creature related to this controller.
      useFlippedSpritesAsFallback - A flag indicating whether this controller should flip the provided spritesheet horizontally to provide a fallback animation for left or right directions.
      See Also:
    • CreatureAnimationController

      public CreatureAnimationController(T creature, Animation defaultAnimation)
      Initializes a new instance of the CreatureAnimationController class.
      Parameters:
      creature - The creature related to this controller.
      defaultAnimation - The default animation for this controller.
      See Also:
    • CreatureAnimationController

      public CreatureAnimationController(T creature, boolean useFlippedSpritesAsFallback, Animation defaultAnimation, Animation... animations)
      Initializes a new instance of the CreatureAnimationController class.
      Parameters:
      creature - The creature related to this controller.
      useFlippedSpritesAsFallback - A flag indicating whether this controller should flip the provided spritesheet horizontally to provide a fallback animation for left or right directions.
      defaultAnimation - The default animation for this controller.
      animations - Additional animations that are managed by this controller instance.
      See Also:
  • Method Details

    • getSpriteName

      public static String getSpriteName(Creature creature, CreatureAnimationState state)
      Gets the sprite name for the specified creature and animation state.
      Parameters:
      creature - The creature to retrieve the sprite name for.
      state - The current animation state.
      Returns:
      A string representing the sprite name for the specified creature in the defined animation state.
      See Also:
    • getSpriteName

      public static String getSpriteName(Creature creature, CreatureAnimationState state, Direction direction)
      Gets the sprite name for the specified creature, animation state.and direction.
      Parameters:
      creature - The creature to retrieve the sprite name for.
      state - The current animation state.
      direction - The direction in which the creature is facing.
      Returns:
      A string representing the sprite name for the specified creature, animation state and facing direction.
      See Also:
    • 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 Creature>
      Overrides:
      isAutoScaling in class EntityAnimationController<T extends Creature>
      Returns:
      True if this instance is automatically scaling to the dimensions of the entity; otherwise false.
    • getSpritePrefix

      protected String getSpritePrefix()
      Overrides:
      getSpritePrefix in class EntityAnimationController<T extends Creature>
    • getCurrentAnimationName

      protected String getCurrentAnimationName()
      This method evaluates the current animation name that depends on certain properties of the EntityAnimationController.getEntity(). Overwriting this method allows to specify more sophisticated animations.
      Returns:
      The name of the current animation that should be played