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 class
EntityAnimationController.AnimationRule<T extends IEntity>
Constructor Summary
Constructors Constructor Description EntityAnimationController(T entity)
Initializes a new instance of theEntityAnimationController
class.EntityAnimationController(T entity, Animation defaultAnimation, Animation... animations)
Initializes a new instance of theEntityAnimationController
class.EntityAnimationController(T entity, Spritesheet sprite)
Initializes a new instance of theEntityAnimationController
class.EntityAnimationController(T entity, Spritesheet sprite, boolean loop)
Initializes a new instance of theEntityAnimationController
class.Method Summary
Modifier and Type Method Description void
addRule(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.void
addRule(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)
T
getEntity()
protected java.lang.String
getSpritePrefix()
boolean
isAutoScaling()
Gets a flag indicating whether this controller instance is auto scaling its animations by the dimensions of the entity.void
scaleSprite(float scale)
Sets the ratio used to scale the animations of this controller instance.void
scaleSprite(float scaleX, float scaleY)
Sets the dimensions used to scale the animations of this controller instance.void
setAutoScaling(boolean scaling)
Sets a value indicating whether this controller instance is auto scaling its animations by the dimensions of the entityprotected void
setSpritePrefix(java.lang.String prefix)
void
update()
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, setEnabled
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods 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 theEntityAnimationController
class.- Parameters:
entity
- The entity related to this animation controller.- See Also:
getEntity()
EntityAnimationController
Initializes a new instance of theEntityAnimationController
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
Initializes a new instance of theEntityAnimationController
class.- 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 theEntityAnimationController
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 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: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 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:
getEntity
in interfaceIEntityController
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 theClientConfiguration
.- Specified by:
update
in interfaceIUpdateable
- Overrides:
update
in 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:IEntityAnimationController
Gets a flag indicating whether this controller instance is auto scaling its animations by the dimensions of the entity.- Specified by:
isAutoScaling
in 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:IEntityAnimationController
Sets a value indicating whether this controller instance is auto scaling its animations by the dimensions of the entity- Specified by:
setAutoScaling
in 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:IEntityAnimationController
Sets the dimensions used to scale the animations of this controller instance.- Specified by:
scaleSprite
in 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:IEntityAnimationController
Sets the ratio used to scale the animations of this controller instance.- Specified by:
scaleSprite
in interfaceIEntityAnimationController<T extends IEntity>
- Parameters:
scale
- The ratio to scale the animation with.