Class CreatureAnimationController<T extends Creature>
java.lang.Object
de.gurkenlabs.litiengine.graphics.animation.AnimationController
de.gurkenlabs.litiengine.graphics.animation.EntityAnimationController<T>
de.gurkenlabs.litiengine.graphics.animation.CreatureAnimationController<T>
- Type Parameters:
T- The type of the creature for which animations are managed by this controller.
- All Implemented Interfaces:
IEntityController,IAnimationController,IEntityAnimationController<T>,IUpdateable
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:
getSpritePrefix()-idle-{DIRECTION}.{EXTENSION}getSpritePrefix()-move-{DIRECTION}.{EXTENSION}
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:
-
Nested Class Summary
Nested classes/interfaces inherited from class de.gurkenlabs.litiengine.graphics.animation.EntityAnimationController
EntityAnimationController.AnimationRule<T extends IEntity> -
Constructor Summary
ConstructorsConstructorDescriptionCreatureAnimationController(T creature, boolean useFlippedSpritesAsFallback) Initializes a new instance of theCreatureAnimationControllerclass.CreatureAnimationController(T creature, boolean useFlippedSpritesAsFallback, Animation defaultAnimation, Animation... animations) Initializes a new instance of theCreatureAnimationControllerclass.CreatureAnimationController(T creature, Animation defaultAnimation) Initializes a new instance of theCreatureAnimationControllerclass. -
Method Summary
Modifier and TypeMethodDescriptionprotected StringThis method evaluates the current animation name that depends on certain properties of theEntityAnimationController.getEntity().static StringgetSpriteName(Creature creature, CreatureAnimationState state) Gets the sprite name for the specified creature and animation state.static StringgetSpriteName(Creature creature, CreatureAnimationState state, Direction direction) Gets the sprite name for the specified creature, animation state.and direction.protected StringbooleanGets a flag indicating whether this controller instance is auto scaling its animations by the dimensions of the entity.Methods inherited from class de.gurkenlabs.litiengine.graphics.animation.EntityAnimationController
addRule, addRule, getDefaultSpritePrefixes, getEntity, scaleSprite, scaleSprite, setAutoScaling, setSpritePrefix, updateMethods inherited from class de.gurkenlabs.litiengine.graphics.animation.AnimationController
add, add, addListener, attach, buildCurrentCacheKey, clear, detach, flippedAnimation, get, getAffineTransform, getAll, getCurrent, getCurrentImage, getCurrentImage, getDefault, getImageEffects, hasAnimation, isEnabled, isPlaying, play, remove, remove, removeListener, setAffineTransform, setDefault, setEnabledMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface de.gurkenlabs.litiengine.graphics.animation.IAnimationController
add, add, addListener, clear, get, getAffineTransform, getAll, getCurrent, getCurrentImage, getCurrentImage, getDefault, getImageEffects, hasAnimation, isEnabled, isPlaying, play, remove, remove, removeListener, setAffineTransform, setDefault, setEnabledMethods inherited from interface de.gurkenlabs.litiengine.entities.IEntityController
attach, detach
-
Constructor Details
-
CreatureAnimationController
Initializes a new instance of theCreatureAnimationControllerclass.- 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
Initializes a new instance of theCreatureAnimationControllerclass.- 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 theCreatureAnimationControllerclass.- 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
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:IEntityAnimationControllerGets a flag indicating whether this controller instance is auto scaling its animations by the dimensions of the entity.- Specified by:
isAutoScalingin interfaceIEntityAnimationController<T extends Creature>- Overrides:
isAutoScalingin classEntityAnimationController<T extends Creature>- Returns:
- True if this instance is automatically scaling to the dimensions of the entity; otherwise false.
-
getSpritePrefix
- Overrides:
getSpritePrefixin classEntityAnimationController<T extends Creature>
-
getCurrentAnimationName
This method evaluates the current animation name that depends on certain properties of theEntityAnimationController.getEntity(). Overwriting this method allows to specify more sophisticated animations.- Returns:
- The name of the current animation that should be played
-