Momentum.State
Constructor and Description |
---|
DefaultMomentum() |
Modifier and Type | Method and Description |
---|---|
Momentum.State |
createState(Point initialPosition,
Point initialVelocity)
Create a
Momentum.State instance. |
boolean |
updateState(Momentum.State state)
Update the state based on the specified
Momentum.State . |
public Momentum.State createState(Point initialPosition, Point initialVelocity)
Momentum
Momentum.State
instance. The Momentum.State
instance will be passed
to Momentum.updateState(State)
until the momentum is depleted.createState
in interface Momentum
initialPosition
- the initial positioninitialVelocity
- the initial velocity in pixels per millisecondpublic boolean updateState(Momentum.State state)
Momentum
Update the state based on the specified Momentum.State
. When no more
momentum remains, this method should return false to stop future calls.
The Momentum.State
instance is created by a call to
Momentum.createState(Point, Point)
, and the same instance if used for the
duration of the momentum. This method should modify the existing state by
calling Momentum.State.setPosition(Point)
and/or
Momentum.State.setVelocity(Point)
.
updateState
in interface Momentum
state
- the current state