Artenus 2D Framework
Artenus Reference
Performs an animation based on the frames contained in an image sprite's cutout. Note that this class targets only image sprites. You must only assign this animation to an instance of ImageSprite.

See Also:

public final class ImageAnimation
implements AnimationHandler

Constructor Summary

Modifier and TypeConstructor and Description
public ImageAnimation(int[] animationFrames)
Creates an ImageAnimation with the given set of frames and a loop trend.
public ImageAnimation(int[] animationFrames, Trends trend)
Creates an ImageAnimation with the given set of frames and trend.
public ImageAnimation(int[] animationFrames, Trends trend, int startIndex)
Creates an ImageAnimation with the given set of frames and trend.

Method Summary

Modifier and TypeMethod and Description
public voidadvance(Animatable sprite, float elapsedTime)
Called whenever the animation should update the image sprite based on elapsed time.
public intgetFrame()
Gets the current frame index of the animation.
public TrendsgetTrend()
Gets the trend of this image animation.
public voidsetFrameDelay(int delay)
Adjusts frame interval for the animation.
public voidsetFrameDelay(float delay)
Adjusts frame interval for the animation.

Methods inherited from java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail

ImageAnimation
public  ImageAnimation(
    int[] animationFrames
)
Creates an ImageAnimation with the given set of frames and a loop trend.
Parameters:
animationFramesThe array of frames from the cutout to animate through
See Also:
ImageAnimation
public  ImageAnimation(
    int[] animationFrames,
    Trends trend
)
Creates an ImageAnimation with the given set of frames and trend.
Parameters:
animationFramesThe array of frames from the cutout to animate through
trendThe trend at which the frames will be animated
See Also:
ImageAnimation
public  ImageAnimation(
    int[] animationFrames,
    Trends trend,
    int startIndex
)
Creates an ImageAnimation with the given set of frames and trend. The animation is started at a given frame index.
Parameters:
animationFramesThe array of frames from the cutout to animate through
trendThe trend at which the frames will be animated
startIndexThe frame index at which the animation should start. This index determines the item in the frame array and not the frame index belonging to the sprite's cutout.
See Also:

Method Detail

advance
public void advance(
    Animatable sprite,
    float elapsedTime
)
Called whenever the animation should update the image sprite based on elapsed time. Frame timing is automatically handled based on your adjustment using setFrameDelay(int).
Specified By:
See Also:
getFrame
public int getFrame()
Gets the current frame index of the animation.
Returns:
The current frame of the animation. This value indicates the index in the frame array, and not the frame index belonging to the sprite's cutout.
See Also:
getTrend
public Trends getTrend()
Gets the trend of this image animation. The value can be one of LOOP, ONCE or PING_PONG.
Returns:
The animation trend
See Also:
setFrameDelay
public void setFrameDelay(
    int delay
)
Adjusts frame interval for the animation. This is a legacy method which is still supported. It is recommended to use setFrameDelay(float) instead as it is guaranteed not to be deprecated in future versions.
Parameters:
delayThe interval between frames in milliseconds
See Also:
setFrameDelay
public void setFrameDelay(
    float delay
)
Adjusts frame interval for the animation. The difference between this method and setFrameDelay(int) is that this method gets the delay in seconds and in floating point format, which is compatible with the rest of the framework.
Parameters:
delayThe interval between frames in seconds
See Also: