1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 09:02:58 +08:00

Fix stutter when showing game HUD after being hidden for a while

This commit is contained in:
Dean Herbert 2020-02-26 20:45:57 +09:00
parent 2c0b8ab95f
commit ed2bdd7106
2 changed files with 14 additions and 8 deletions

View File

@ -13,12 +13,5 @@ namespace osu.Game.Screens.Play.HUD
MinValue = 0,
MaxValue = 1
};
protected HealthDisplay()
{
Current.ValueChanged += health => SetHealth((float)health.NewValue);
}
protected abstract void SetHealth(float value);
}
}

View File

@ -12,6 +12,7 @@ using osu.Game.Rulesets.Judgements;
using osuTK;
using osuTK.Graphics;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Utils;
using osu.Game.Rulesets.Scoring;
namespace osu.Game.Screens.Play.HUD
@ -108,11 +109,23 @@ namespace osu.Game.Screens.Play.HUD
if (result.Type == HitResult.Miss)
return;
Scheduler.AddOnce(flash);
}
private void flash()
{
fill.FadeEdgeEffectTo(Math.Min(1, fill.EdgeEffect.Colour.Linear.A + (1f - base_glow_opacity) / glow_max_hits), 50, Easing.OutQuint)
.Delay(glow_fade_delay)
.FadeEdgeEffectTo(base_glow_opacity, glow_fade_time, Easing.OutQuint);
}
protected override void SetHealth(float value) => fill.ResizeTo(new Vector2(value, 1), 200, Easing.OutQuint);
protected override void Update()
{
base.Update();
fill.Width = Interpolation.ValueAt(
Math.Clamp(Clock.ElapsedFrameTime, 0, 200),
fill.Width, (float)Current.Value, 0, 200, Easing.OutQuint);
}
}
}