Artenus 2D Framework
Artenus Reference
Performs a spring-like animation on an entity. This animation is NOT a complete physical simulation of a spring, and is just a loose visual effect that can be used for various screen elements such as menus and buttons.
public final class SpringAnimation
implements AnimationHandler

Field Summary

Modifier and TypeField and Description
public static final ROTATION
Specifies the spring animation should affect the entity's rotational angle.
public static final SCALE
Specifies the spring animation should affect the entity's scale.
public static final X
Specifies the animation should affect the x component of the entity's position.
public static final Y
Specifies the spring animation should affect the y component of the entity's position.

Constructor Summary

Modifier and TypeConstructor and Description
public SpringAnimation(int type, float initial, float target)
Creates a SpringAnimation with the give type and values.
public SpringAnimation(int type, float initial, float target, float kValue, float decayFactor)
Creates a SpringAnimation with the give type and values.

Method Summary

Modifier and TypeMethod and Description
public final voidadvance(Animatable animatable, float elapsedTime)
Called whenever the animation should update the animatable based on elapsed time.
public floatgetCurrentValue()
Gets the current value of the property used in the animation.
public floatgetTargetValue()
Gets the target value of the property used in the animation.
public final intgetType()
Gets the spring animation type of this SpringAnimation object.
public final voidsetTargetValue(float value)
Gets the target value of the property used in the animation.

Methods inherited from java.lang.Object

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

Field Detail

ROTATION
public static final ROTATION
Specifies the spring animation should affect the entity's rotational angle.
SCALE
public static final SCALE
Specifies the spring animation should affect the entity's scale.
X
public static final X
Specifies the animation should affect the x component of the entity's position.
Y
public static final Y
Specifies the spring animation should affect the y component of the entity's position.

Constructor Detail

SpringAnimation
public  SpringAnimation(
    int type,
    float initial,
    float target
)
Creates a SpringAnimation with the give type and values. The animation will involve the selected component bounce back and forth centered on the target value in a spring motion. For more control over the spring motion, use SpringAnimation(int, float, float, float, float).
Parameters:
typeThe type of the animation which indicates the property of the entity the spring motion will affect
initialThe initial value of the selected property for the animation
targetThe target value of the selected property for the animation
See Also:
SpringAnimation
public  SpringAnimation(
    int type,
    float initial,
    float target,
    float kValue,
    float decayFactor
)
Creates a SpringAnimation with the give type and values. The animation will involve the selected component oscillate centered on the target value in a spring motion. You can also specify the K value of the spring and a decay factor to make the motion slow down gradually.
Parameters:
typeThe type of the animation which indicates the property of the entity the spring motion will affect
initialThe initial value of the selected property for the animation
targetThe target value of the selected property for the animation
kValueThe K value of the spring, which determines how quickly it will bounce back from a stretched position
decayFactorThe decay factor of the spring motion; if this value is set to any number above zero, the motion will decayed until it reaches a halt; the speed of decay is determined by the value of this parameter

Method Detail

advance
public final void advance(
    Animatable animatable,
    float elapsedTime
)
Called whenever the animation should update the animatable based on elapsed time.
Specified By:
getCurrentValue
public float getCurrentValue()
Gets the current value of the property used in the animation.
Returns:
The value of the selected property; selected property is determined by animation type
See Also:
getTargetValue
public float getTargetValue()
Gets the target value of the property used in the animation. The target value can be viewed as the center of oscillation.
Returns:
The target value of the selected property; selected property is determined by animation type
See Also:
getType
public final int getType()
Gets the spring animation type of this SpringAnimation object.
Returns:
The type of spring, which indicates the property of the entity that is affected by the animation
See Also:
setTargetValue
public final void setTargetValue(
    float value
)
Gets the target value of the property used in the animation. The target value can be viewed as the center of oscillation.
Parameters:
valueTarget value of the selected property; selected property is determined by animation type
See Also: