public final class InterpolatedFloatValue
extends java.lang.Object
An interpolated value stores the initial value as well as the current value of a variable. The interpolated value may be used during rendering.
// Example: Updating health stored as a float FloatInterpolatedValue health = new FloatInterpolatedValue(Interpolators.linearFloat()); health.setInitialValue(10f); health.setCurrentValue(10f); // Set initial value prior to any changes float currentHealth = health.getCurrentValue(); health.setInitialValue(currentHealth); // Update current value as you normally would currentHealth -= 5f; health.setCurrentValue(currentHealth); // Get the interpolated value float interpolatedHp = health.getInterpolatedValue(0.5f); Assert.assertEquals(interpolatedHp, 7.5f);
| Constructor and Description |
|---|
InterpolatedFloatValue(FloatInterpolator interpolator)
Constructs the
InterpolatedFloatValue |
| Modifier and Type | Method and Description |
|---|---|
float |
getCurrentValue()
Gets the current value
|
float |
getInitialValue()
The initial value
|
float |
getInterpolatedValue(float alpha)
Gets the interpolated value at the specified alpha
|
void |
setCurrentValue(float currentValue)
Sets the current value
|
void |
setInitialValue(float initialValue)
Sets the initial value
|
public InterpolatedFloatValue(FloatInterpolator interpolator)
InterpolatedFloatValueinterpolator - the interpolator functionpublic float getInitialValue()
public void setInitialValue(float initialValue)
initialValue - the new initial valuepublic float getCurrentValue()
public void setCurrentValue(float currentValue)
currentValue - the new current valuepublic float getInterpolatedValue(float alpha)
alpha - the alpha is a value between 0.0f and 1.0f