Package com.xebisco.yield
Class AnimationPlayer
java.lang.Object
com.xebisco.yield.AbstractBehavior
com.xebisco.yield.ComponentBehavior
com.xebisco.yield.AnimationPlayer
- All Implemented Interfaces:
Behavior,Renderable,Closeable,AutoCloseable
The AnimationPlayer class is a component behavior that handles the playing of animations by updating the texture
rectangle with the current frame.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintReturns the index of the current frame in the animation.Returns the currently playing animation.Returns the currently playing animation.voidonUpdate(ContextTime time) This method is called every frame to update the animation player.setActualFrame(int actualFrame) Sets the index of the current frame in the animation.setAnimation(Animation animation) Sets the current animation to the given animation.setToChange(double toChange) Sets the time since the last frame change.setToSwitchAnimation(Animation toSwitchAnimation) Sets the animation that will be played after the current animation finishes.doubletoChange()Returns the time since the last frame change.Returns the animation that will be played after the current animation finishes.Methods inherited from class com.xebisco.yield.ComponentBehavior
application, close, component, component, entity, onCreate, onLateUpdate, onStart, render, renderIndex, setEntity, setRenderIndex, texture, texture, transformMethods inherited from class com.xebisco.yield.AbstractBehavior
frames, tick
-
Constructor Details
-
AnimationPlayer
public AnimationPlayer()
-
-
Method Details
-
onUpdate
This method is called every frame to update the animation player.- Specified by:
onUpdatein interfaceBehavior- Overrides:
onUpdatein classComponentBehavior- Parameters:
time- The context time, containing delta time.
-
getAnimation
Returns the currently playing animation.- Returns:
- The currently playing animation.
-
setAnimation
Sets the current animation to the given animation.- Parameters:
animation- The animation to set.- Returns:
- This AnimationPlayer instance.
-
animation
Returns the currently playing animation.- Returns:
- The currently playing animation.
-
toSwitchAnimation
Returns the animation that will be played after the current animation finishes.- Returns:
- The animation that will be played after the current animation finishes.
-
setToSwitchAnimation
Sets the animation that will be played after the current animation finishes.- Parameters:
toSwitchAnimation- The animation to set.- Returns:
- This AnimationPlayer instance.
-
actualFrame
public int actualFrame()Returns the index of the current frame in the animation.- Returns:
- The index of the current frame in the animation.
-
setActualFrame
Sets the index of the current frame in the animation.- Parameters:
actualFrame- The index of the frame to set.- Returns:
- This AnimationPlayer instance.
-
toChange
public double toChange()Returns the time since the last frame change.- Returns:
- The time since the last frame change.
-
setToChange
Sets the time since the last frame change.- Parameters:
toChange- The time to set.- Returns:
- This AnimationPlayer instance.
-