public class Spring
extends java.lang.Object
This code was forked from the facebook/rebound repository.
Constructor and Description |
---|
Spring()
create a new spring
|
Modifier and Type | Method and Description |
---|---|
Spring |
addListener(SpringListener newListener)
add a listener
|
void |
advance(double realDeltaTime)
advance the physics simulation in SOLVER_TIMESTEP_SEC sized chunks to fulfill the required
realTimeDelta.
|
boolean |
currentValueIsApproximately(double value)
This method checks to see that the current spring displacement value is equal to the input,
accounting for the spring's rest displacement threshold.
|
void |
destroy()
Destroys this Spring, meaning that it will be deregistered from its BaseSpringSystem so it
won't be iterated anymore and will clear its set of listeners.
|
double |
getCurrentDisplacementDistance()
get the displacement of the springs current value from its rest value.
|
double |
getCurrentValue()
Get the current
|
double |
getEndValue()
get the rest value used for determining the displacement of the spring
|
java.lang.String |
getId()
get the unique id for this spring
|
double |
getRestDisplacementThreshold()
get the threshold of displacement from rest below which the spring should be considered at rest
|
double |
getRestSpeedThreshold()
Returns the speed at which the spring should be considered at rest in pixels per second
|
SpringConfig |
getSpringConfig()
retrieve the spring config for this spring
|
double |
getStartValue()
Get the displacement value from the last time setCurrentValue was called.
|
double |
getVelocity()
get the velocity of the spring
|
boolean |
isAtRest()
check if the current state is at rest
|
boolean |
isOvershootClampingEnabled()
Check if overshoot clamping is enabled.
|
boolean |
isOvershooting()
Check if the spring is overshooting beyond its target.
|
Spring |
removeAllListeners()
remove all of the listeners
|
Spring |
removeListener(SpringListener listenerToRemove)
remove a listener
|
Spring |
setAtRest()
Set the spring to be at rest by making its end value equal to its current value and setting
velocity to 0.
|
Spring |
setCurrentValue(double currentValue)
Set the displaced value to determine the displacement for the spring from the rest value.
|
Spring |
setCurrentValue(double currentValue,
boolean setAtRest)
The full signature for setCurrentValue includes the option of not setting the spring at rest
after updating its currentValue.
|
Spring |
setEndValue(double endValue)
set the rest value to determine the displacement for the spring
|
Spring |
setOvershootClampingEnabled(boolean overshootClampingEnabled)
Force the spring to clamp at its end value to avoid overshooting the target value.
|
Spring |
setRestDisplacementThreshold(double displacementFromRestThreshold)
set the threshold of displacement from rest below which the spring should be considered at rest
|
Spring |
setRestSpeedThreshold(double restSpeedThreshold)
Sets the speed at which the spring should be considered at rest.
|
Spring |
setSpringConfig(SpringConfig springConfig)
set the config class
|
Spring |
setVelocity(double velocity)
set the velocity on the spring in pixels per second
|
boolean |
systemShouldAdvance()
Check if this spring should be advanced by the system.
|
boolean |
wasAtRest()
Check if the spring was at rest in the prior iteration.
|
public void destroy()
public java.lang.String getId()
public Spring setSpringConfig(SpringConfig springConfig)
springConfig
- config class for the springpublic SpringConfig getSpringConfig()
public Spring setCurrentValue(double currentValue)
currentValue
- the new start and current value for the springpublic Spring setCurrentValue(double currentValue, boolean setAtRest)
currentValue
- the new start and current value for the springsetAtRest
- optionally set the spring at rest after updating its current value. see com.facebook.rebound.Spring#setAtRest()
public double getStartValue()
public double getCurrentValue()
public double getCurrentDisplacementDistance()
public Spring setEndValue(double endValue)
endValue
- the endValue for the springpublic double getEndValue()
public Spring setVelocity(double velocity)
velocity
- velocity valuepublic double getVelocity()
public Spring setRestSpeedThreshold(double restSpeedThreshold)
restSpeedThreshold
- speed pixels per secondpublic double getRestSpeedThreshold()
public Spring setRestDisplacementThreshold(double displacementFromRestThreshold)
displacementFromRestThreshold
- displacement to consider resting belowpublic double getRestDisplacementThreshold()
public Spring setOvershootClampingEnabled(boolean overshootClampingEnabled)
overshootClampingEnabled
- whether or not to enable overshoot clampingpublic boolean isOvershootClampingEnabled()
public boolean isOvershooting()
public void advance(double realDeltaTime)
realDeltaTime
- clock driftpublic boolean systemShouldAdvance()
public boolean wasAtRest()
public boolean isAtRest()
public Spring setAtRest()
public Spring addListener(SpringListener newListener)
newListener
- to addpublic Spring removeListener(SpringListener listenerToRemove)
listenerToRemove
- to removepublic Spring removeAllListeners()
public boolean currentValueIsApproximately(double value)
value
- The value to compare the spring value to