feat: additive transform tweens added
This commit is contained in:
parent
cd30047e4a
commit
feb2a05aa3
@ -39,4 +39,69 @@ public static class TweenTransform2DExtensions
|
||||
float initialLocalRotation = transform2D.LocalRotation;
|
||||
return tweenManager.StartTween(duration, t => transform2D.LocalRotation = initialLocalRotation.Lerp(targetLocalRotation, t));
|
||||
}
|
||||
public static ITween TweenPositionAdditive(this ITransform2D transform2D, ITweenManager tweenManager, float duration, Vector2D additivePosition)
|
||||
{
|
||||
Vector2D progressedPosition = Vector2D.Zero;
|
||||
return tweenManager.StartTween(duration, t =>
|
||||
{
|
||||
Vector2D displacement = Vector2D.Zero.Lerp(additivePosition, t) - progressedPosition;
|
||||
transform2D.Position += displacement;
|
||||
progressedPosition += displacement;
|
||||
});
|
||||
}
|
||||
|
||||
public static ITween TweenScaleAdditive(this ITransform2D transform2D, ITweenManager tweenManager, float duration, Vector2D additiveScale)
|
||||
{
|
||||
Vector2D progressedScale = Vector2D.Zero;
|
||||
return tweenManager.StartTween(duration, t =>
|
||||
{
|
||||
Vector2D displacement = Vector2D.Zero.Lerp(additiveScale, t) - progressedScale;
|
||||
transform2D.Scale += displacement;
|
||||
progressedScale += displacement;
|
||||
});
|
||||
}
|
||||
|
||||
public static ITween TweenRotationAdditive(this ITransform2D transform2D, ITweenManager tweenManager, float duration, float additiveRotation)
|
||||
{
|
||||
float progressedRotation = 0f;
|
||||
return tweenManager.StartTween(duration, t =>
|
||||
{
|
||||
float displacement = 0f.Lerp(additiveRotation, t) - progressedRotation;
|
||||
transform2D.Rotation += displacement;
|
||||
progressedRotation += displacement;
|
||||
});
|
||||
}
|
||||
|
||||
public static ITween TweenLocalPositionAdditive(this ITransform2D transform2D, ITweenManager tweenManager, float duration, Vector2D additiveLocalPosition)
|
||||
{
|
||||
Vector2D progressedLocalPosition = Vector2D.Zero;
|
||||
return tweenManager.StartTween(duration, t =>
|
||||
{
|
||||
Vector2D displacement = Vector2D.Zero.Lerp(additiveLocalPosition, t) - progressedLocalPosition;
|
||||
transform2D.LocalPosition += displacement;
|
||||
progressedLocalPosition += displacement;
|
||||
});
|
||||
}
|
||||
|
||||
public static ITween TweenLocalScaleAdditive(this ITransform2D transform2D, ITweenManager tweenManager, float duration, Vector2D additiveLocalScale)
|
||||
{
|
||||
Vector2D progressedLocalScale = Vector2D.Zero;
|
||||
return tweenManager.StartTween(duration, t =>
|
||||
{
|
||||
Vector2D displacement = Vector2D.Zero.Lerp(additiveLocalScale, t) - progressedLocalScale;
|
||||
transform2D.LocalScale += displacement;
|
||||
progressedLocalScale += displacement;
|
||||
});
|
||||
}
|
||||
|
||||
public static ITween TweenLocalRotationAdditive(this ITransform2D transform2D, ITweenManager tweenManager, float duration, float additiveLocalRotation)
|
||||
{
|
||||
float progressedLocalRotation = 0f;
|
||||
return tweenManager.StartTween(duration, t =>
|
||||
{
|
||||
float displacement = 0f.Lerp(additiveLocalRotation, t) - progressedLocalRotation;
|
||||
transform2D.LocalRotation += displacement;
|
||||
progressedLocalRotation += displacement;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user