Interface IAnimationController
- All Superinterfaces:
IUpdateable
- All Known Subinterfaces:
IEntityAnimationController<T>
- All Known Implementing Classes:
AnimationController
,CreatureAnimationController
,EntityAnimationController
,PropAnimationController
public interface IAnimationController
extends IUpdateable
Method Summary
Modifier and Type Method Description void
add(Animation animation)
Add the specifiedAnimation
to this controller instance.void
add(ImageEffect effect)
Adds the specifiedImageEffect
to be applied when the current image is retrieved from this controller.void
addListener(AnimationListener listener)
Adds the specified animation listener to receive events and callbacks when animation playbacks are started and finished.void
clear()
Remove allAnimation
s from theAnimationController
.Animation
get(java.lang.String animationName)
Gets theAnimation
instance with the specified name from this controller.java.awt.geom.AffineTransform
getAffineTransform()
Gets theAffineTransform
instance assigned to this controller that can be used to externally transform the current image when rendering it with theImageRenderer
.java.util.Collection<Animation>
getAll()
Gets allAnimation
instances managed by this controller.Animation
getCurrent()
Gets the currently activeAnimation
of this controller.java.awt.image.BufferedImage
getCurrentImage()
Gets the current sprite (keyframe) of the currently active animation of this controller.java.awt.image.BufferedImage
getCurrentImage(int width, int height)
Gets the current sprite scaled by the specified dimensions of the currently active animation of this controller.Animation
getDefault()
Gets the defaultAnimation
of this controller.java.util.List<ImageEffect>
getImageEffects()
Gets all image effects assigned to this controller.boolean
hasAnimation(java.lang.String animationName)
Determines whether this controller has anAnimation
with the specified name.boolean
isEnabled()
Determines whether this controller is currently enabled.boolean
isPlaying(java.lang.String animationName)
Determines whether this controller is currently playing anAnimation
with the specified name.void
play(java.lang.String animationName)
Plays theAnimation
with the specified name.void
remove(Animation animation)
Removes the specifiedAnimation
from this controller instance.void
remove(ImageEffect effect)
Removes the specifiedImageEffect
from this controller.void
removeListener(AnimationListener listener)
Removes the specified animation listener.void
setAffineTransform(java.awt.geom.AffineTransform affineTransform)
Sets theAffineTransform
instance for this controller that can be used to externally transform the current image when rendering it with theImageRenderer
.void
setDefault(Animation animation)
Sets the specifiedAnimation
as default for this controller.void
setEnabled(boolean enabled)
Sets a flag that defines whether this controller is enabled or not.
Method Details
addListener
Adds the specified animation listener to receive events and callbacks when animation playbacks are started and finished.- Parameters:
listener
- The listener to add.
removeListener
Removes the specified animation listener.- Parameters:
listener
- The listener to remove.
add
Add the specifiedAnimation
to this controller instance.Animations with the same name will be replaced by this method.
- Parameters:
animation
- The animation to add.- See Also:
remove(Animation)
,hasAnimation(String)
,clear()
remove
Removes the specifiedAnimation
from this controller instance.- Parameters:
animation
- The animation to remove.- See Also:
add(Animation)
,hasAnimation(String)
,clear()
clear
void clear()Remove allAnimation
s from theAnimationController
.getAll
java.util.Collection<Animation> getAll()Gets allAnimation
instances managed by this controller.- Returns:
- All
Animation
instances.
get
Gets theAnimation
instance with the specified name from this controller.The name of an
Animation
is case sensitive.- Parameters:
animationName
- The name of the animation.- Returns:
- The animation with the specified name or null if no such animation is managed by this controller.
- See Also:
getCurrent()
,getDefault()
,hasAnimation(String)
getCurrent
Animation getCurrent()Gets the currently activeAnimation
of this controller.The current active animation provides the current image that is being rendered by consumers of this controller (e.g. the render engine or any explicit, custom render mechanism).
- Returns:
- The currently active animation.
- See Also:
getDefault()
,get(String)
,RenderEngine.renderEntity(java.awt.Graphics2D, de.gurkenlabs.litiengine.entities.IEntity)
getDefault
Animation getDefault()Gets the defaultAnimation
of this controller.This animation is played when no other animation is currently active.
- Returns:
- The default animation of this controller.
- See Also:
getCurrent()
,get(String)
,setDefault(Animation)
hasAnimation
boolean hasAnimation(java.lang.String animationName)Determines whether this controller has anAnimation
with the specified name.The name of an
Animation
is case sensitive.- Parameters:
animationName
- The name of the animation.- Returns:
- True if this controller contains an
Animation
with the specified name; otherwise false. - See Also:
add(Animation)
,remove(Animation)
isPlaying
boolean isPlaying(java.lang.String animationName)Determines whether this controller is currently playing anAnimation
with the specified name.The name of an
Animation
is case sensitive.- Parameters:
animationName
- The name of the animation.- Returns:
- True if this controller is currently playing the
Animation
with the specified name. - See Also:
getCurrent()
play
void play(java.lang.String animationName)Plays theAnimation
with the specified name.Does nothing if this controller doesn't contain an
Animation
with the specified name.This method also publishes the "played" event to all subscribed
AnimationListener
instances.- Parameters:
animationName
- The name of theAnimation
to be played.- See Also:
AnimationListener.played(Animation)
,getCurrent()
setDefault
Sets the specifiedAnimation
as default for this controller.- Parameters:
animation
- The animation to be set as default.- See Also:
getDefault()
getCurrentImage
java.awt.image.BufferedImage getCurrentImage()Gets the current sprite (keyframe) of the currently active animation of this controller.The implementation of this method applies all registered
ImageEffects
.- Returns:
- The current sprite of the current animation with applied effects; or null, if this controller is currently disabled.
- See Also:
getCurrent()
,Animation.getCurrentKeyFrame()
,isEnabled()
getCurrentImage
java.awt.image.BufferedImage getCurrentImage(int width, int height)Gets the current sprite scaled by the specified dimensions of the currently active animation of this controller.The implementation of this method applies all registered
ImageEffects
.- Parameters:
width
- The width of the image.height
- The height of the image.- Returns:
- The current sprite of the current animation scaled by the defined dimensions with applied effects; or null, if this controller is currently disabled.
- See Also:
getCurrent()
,getCurrentImage()
,Animation.getCurrentKeyFrame()
,isEnabled()
getAffineTransform
java.awt.geom.AffineTransform getAffineTransform()Gets theAffineTransform
instance assigned to this controller that can be used to externally transform the current image when rendering it with theImageRenderer
.- Returns:
- The
AffineTransform
instance assigned to this controller or null. - See Also:
AffineTransform
,ImageRenderer.renderTransformed(java.awt.Graphics2D, java.awt.Image, AffineTransform)
,setAffineTransform(AffineTransform)
,getCurrentImage()
setAffineTransform
void setAffineTransform(java.awt.geom.AffineTransform affineTransform)Sets theAffineTransform
instance for this controller that can be used to externally transform the current image when rendering it with theImageRenderer
.- Parameters:
affineTransform
- TheAffineTransform
instance for this controller.- See Also:
AffineTransform
,getAffineTransform()
add
Adds the specifiedImageEffect
to be applied when the current image is retrieved from this controller.- Parameters:
effect
- The image effect to be added.
remove
Removes the specifiedImageEffect
from this controller.- Parameters:
effect
- The image effect to be removed.
getImageEffects
java.util.List<ImageEffect> getImageEffects()Gets all image effects assigned to this controller.- Returns:
- All image effects of this controller.
- See Also:
add(ImageEffect)
,remove(ImageEffect)
isEnabled
boolean isEnabled()Determines whether this controller is currently enabled.- Returns:
- True if this controller is enabled; otherwise false.
setEnabled
void setEnabled(boolean enabled)Sets a flag that defines whether this controller is enabled or not.- Parameters:
enabled
- True if the controller should be enabled; otherwise false.