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 Classes Modifier and Type Class Description protected static classEntityAnimationController.AnimationRule<T extends IEntity>Constructor Summary
Constructors Constructor Description EntityAnimationController(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 Type Method Description voidaddRule(java.util.function.Predicate<? super T> rule, java.util.function.Function<? super T,java.lang.String> animationName)Registers an animation rule that will be evaluated if there is currently no animation playing that is defined to loop.voidaddRule(java.util.function.Predicate<? super T> rule, java.util.function.Function<? super T,java.lang.String> animationName, int priority)Registers an animation rule that will be evaluated if there is currently no animation playing that is defined to loop.static java.lang.String[]getDefaultSpritePrefixes(java.lang.Class<?> cls)TgetEntity()protected java.lang.StringgetSpritePrefix()booleanisAutoScaling()Gets 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(java.lang.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, flipAnimation, 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, setEnabled
Constructor Details
EntityAnimationController
Initializes a new instance of theEntityAnimationControllerclass.- Parameters:
entity- The entity related to this animation controller.- See Also:
getEntity()
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:
getEntity(),AnimationController.getDefault(),AnimationController.getAll()
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
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: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
public void addRule(java.util.function.Predicate<? super T> rule, java.util.function.Function<? super T,java.lang.String> animationName)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:
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: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.
