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>
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static class -
Constructor Summary
ConstructorsConstructorDescriptionEntityAnimationController(T entity) Initializes a new instance of theEntityAnimationControllerclass.EntityAnimationController(T entity, Animation defaultAnimation, Animation... animations) Initializes a new instance of theEntityAnimationControllerclass.EntityAnimationController(T entity, Spritesheet sprite) Initializes a new instance of theEntityAnimationControllerclass.EntityAnimationController(T entity, Spritesheet sprite, boolean loop) Initializes a new instance of theEntityAnimationControllerclass. -
Method Summary
Modifier and TypeMethodDescriptionvoidRegisters an animation rule that will be evaluated if there is currently no animation playing that is defined to loop.voidRegisters an animation rule that will be evaluated if there is currently no animation playing that is defined to loop.static String[]getDefaultSpritePrefixes(Class<?> cls) protected StringbooleanGets a flag indicating whether this controller instance is auto scaling its animations by the dimensions of the entity.voidscaleSprite(float scale) Sets the ratio used to scale the animations of this controller instance.voidscaleSprite(float scaleX, float scaleY) Sets the dimensions used to scale the animations of this controller instance.voidsetAutoScaling(boolean scaling) Sets a value indicating whether this controller instance is auto scaling its animations by the dimensions of the entityprotected voidsetSpritePrefix(String prefix) voidupdate()This method is called by the game loop on all objects that are attached to the loop.Methods 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
-
EntityAnimationController
Initializes a new instance of theEntityAnimationControllerclass.- Parameters:
entity- The entity related to this animation controller.- See Also:
-
EntityAnimationController
Initializes a new instance of theEntityAnimationControllerclass.- 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:
-
EntityAnimationController
Initializes a new instance of theEntityAnimationControllerclass.- Parameters:
entity- The entity related to this animation controller.sprite- The sprite sheet used by the default animation of this controller.
-
EntityAnimationController
Initializes a new instance of theEntityAnimationControllerclass.- 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
-
addRule
public void addRule(Predicate<? super T> rule, Function<? super T, String> animationName, int priority) Description copied from interface:IEntityAnimationControllerRegisters 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:
addRulein interfaceIEntityAnimationController<T extends IEntity>- Parameters:
rule- The rule that must be fulfilled for the animation to be appliedanimationName- The callback that evaluates the actual animation name that will be appliedpriority- The priority that defines the order in which the rule will be processed. Rules with higher priorities will be processed first.
-
addRule
Description copied from interface:IEntityAnimationControllerRegisters 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:
addRulein interfaceIEntityAnimationController<T extends IEntity>- Parameters:
rule- The rule that must be fulfilled for the animation to be appliedanimationName- The callback that evaluates the actual animation name that will be applied
-
getEntity
- Specified by:
getEntityin interfaceIEntityController
-
update
public void update()Description copied from interface:IUpdateableThis 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 theClientConfiguration.- Specified by:
updatein interfaceIUpdateable- Overrides:
updatein classAnimationController- See Also:
-
getSpritePrefix
-
setSpritePrefix
-
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 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:IEntityAnimationControllerSets a value indicating whether this controller instance is auto scaling its animations by the dimensions of the entity- Specified by:
setAutoScalingin interfaceIEntityAnimationController<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:IEntityAnimationControllerSets the dimensions used to scale the animations of this controller instance.- Specified by:
scaleSpritein interfaceIEntityAnimationController<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:IEntityAnimationControllerSets the ratio used to scale the animations of this controller instance.- Specified by:
scaleSpritein interfaceIEntityAnimationController<T extends IEntity>- Parameters:
scale- The ratio to scale the animation with.
-