mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 16:52:55 +08:00
Avoid transforms per hp change
This commit is contained in:
parent
a810f56ec8
commit
f28bcabae7
@ -1,11 +1,13 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osu.Framework.Utils;
|
||||||
using osu.Game.Rulesets.Judgements;
|
using osu.Game.Rulesets.Judgements;
|
||||||
using osu.Game.Screens.Play.HUD;
|
using osu.Game.Screens.Play.HUD;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
@ -17,6 +19,9 @@ namespace osu.Game.Skinning
|
|||||||
private readonly Skin skin;
|
private readonly Skin skin;
|
||||||
private Sprite fill;
|
private Sprite fill;
|
||||||
private Marker marker;
|
private Marker marker;
|
||||||
|
|
||||||
|
private float maxFillWidth;
|
||||||
|
|
||||||
public Bindable<double> Current { get; } = new BindableDouble { MinValue = 0, MaxValue = 1 };
|
public Bindable<double> Current { get; } = new BindableDouble { MinValue = 0, MaxValue = 1 };
|
||||||
|
|
||||||
public LegacyHealthDisplay(Skin skin)
|
public LegacyHealthDisplay(Skin skin)
|
||||||
@ -45,25 +50,18 @@ namespace osu.Game.Skinning
|
|||||||
Current = { BindTarget = Current },
|
Current = { BindTarget = Current },
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
|
||||||
protected override void LoadComplete()
|
maxFillWidth = fill.Width;
|
||||||
{
|
|
||||||
base.LoadComplete();
|
|
||||||
|
|
||||||
Current.BindValueChanged(updateHp, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateHp(ValueChangedEvent<double> hp)
|
|
||||||
{
|
|
||||||
if (fill.Texture != null)
|
|
||||||
fill.ResizeWidthTo((float)(fill.Texture.DisplayWidth * hp.NewValue), 500, Easing.OutQuint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
|
|
||||||
|
fill.Width = Interpolation.ValueAt(
|
||||||
|
Math.Clamp(Clock.ElapsedFrameTime, 0, 200),
|
||||||
|
fill.Width, (float)Current.Value * maxFillWidth, 0, 200, Easing.OutQuint);
|
||||||
|
|
||||||
marker.Position = fill.Position + new Vector2(fill.DrawWidth, fill.DrawHeight / 2);
|
marker.Position = fill.Position + new Vector2(fill.DrawWidth, fill.DrawHeight / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user