Class DragGesture.DampingMotionStrategy
- Namespace
- Lime
- Assembly
- Lime.dll
Motion damping based on Gauss error function. Duration is calculated so motion lasts until min speed reached.
public class DragGesture.DampingMotionStrategy : DragGesture.IMotionStrategy
- Inheritance
-
DragGesture.DampingMotionStrategy
- Implements
- Inherited Members
Constructors
DampingMotionStrategy(float, float, float, float)
public DampingMotionStrategy(float dampingFactor1, float dampingFactor2, float minSpeed = 25, float maxStartSpeed = Infinity)
Parameters
dampingFactor1
floatInitial speed damping factor. Should be in range (0; 1]. The lower the dampingFactor2, the lower damingFactor1 can be. Otherwise it may result in overflow.
dampingFactor2
floatDamping factor applied to speed damping factor each frame. Valid range is (0; 1).
minSpeed
floatThe minimum speed that is considered a full stop.
maxStartSpeed
floatMaximum initial speed of movement.
Properties
Duration
public float Duration { get; }
Property Value
Position
public Vector2 Position { get; }
Property Value
Methods
Start(Vector2, IEnumerable<(Vector2 Distance, float Duration)>)
Start position calculation.
public bool Start(Vector2 startPosition, IEnumerable<(Vector2 Distance, float Duration)> touchHistory)
Parameters
startPosition
Vector2The position motion should begin at.
touchHistory
IEnumerable<(Vector2 Distance, float Duration)>Sequence of distance and duration pairs for a couple of last frames.
Returns
Update(float)
Recalculates position.
public void Update(float time)
Parameters
time
floatTime elapsed from the start.