mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 07:33:20 +08:00
Use Interpolation.ValueAt instead of manually interpolating FL position.
This commit is contained in:
parent
f7806bc205
commit
1809c996bb
@ -37,7 +37,6 @@ namespace osu.Game.Rulesets.Osu.Mods
|
|||||||
private class OsuFlashlight : Flashlight, IRequireHighFrequencyMousePosition
|
private class OsuFlashlight : Flashlight, IRequireHighFrequencyMousePosition
|
||||||
{
|
{
|
||||||
private const double follow_delay = 120;
|
private const double follow_delay = 120;
|
||||||
private double lastPositionUpdate;
|
|
||||||
|
|
||||||
public OsuFlashlight()
|
public OsuFlashlight()
|
||||||
{
|
{
|
||||||
@ -55,13 +54,8 @@ namespace osu.Game.Rulesets.Osu.Mods
|
|||||||
var position = FlashlightPosition;
|
var position = FlashlightPosition;
|
||||||
var destination = e.MousePosition;
|
var destination = e.MousePosition;
|
||||||
|
|
||||||
double frameTime = Clock.CurrentTime - lastPositionUpdate;
|
FlashlightPosition = Interpolation.ValueAt(MathHelper.Clamp(Clock.ElapsedFrameTime, 0, follow_delay), position, destination, 0, follow_delay, Easing.Out);
|
||||||
double interp = Interpolation.ApplyEasing(Easing.Out, MathHelper.Clamp(frameTime / follow_delay, 0, 1));
|
|
||||||
FlashlightPosition = new Vector2(
|
|
||||||
(float)Interpolation.Lerp(position.X, destination.X, interp),
|
|
||||||
(float)Interpolation.Lerp(position.Y, destination.Y, interp)
|
|
||||||
);
|
|
||||||
lastPositionUpdate = Clock.CurrentTime;
|
|
||||||
return base.OnMouseMove(e);
|
return base.OnMouseMove(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user