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

Add flash effect on click

This commit is contained in:
Dean Herbert 2022-04-26 18:03:34 +09:00
parent 6864623bac
commit 4bc4ff179a

View File

@ -62,6 +62,8 @@ namespace osu.Game.Graphics.UserInterface
private Colour4? lighterColour; private Colour4? lighterColour;
private Colour4? textColour; private Colour4? textColour;
private readonly Box flashLayer;
/// <summary> /// <summary>
/// Creates a new <see cref="ShearedToggleButton"/> /// Creates a new <see cref="ShearedToggleButton"/>
/// </summary> /// </summary>
@ -95,7 +97,14 @@ namespace osu.Game.Graphics.UserInterface
Origin = Anchor.Centre, Origin = Anchor.Centre,
Font = OsuFont.TorusAlternate.With(size: 17), Font = OsuFont.TorusAlternate.With(size: 17),
Shear = new Vector2(-shear, 0) Shear = new Vector2(-shear, 0)
} },
flashLayer = new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Colour4.White.Opacity(0.9f),
Blending = BlendingParameters.Additive,
Alpha = 0,
},
}; };
if (width != null) if (width != null)
@ -121,6 +130,14 @@ namespace osu.Game.Graphics.UserInterface
FinishTransforms(true); FinishTransforms(true);
} }
protected override bool OnClick(ClickEvent e)
{
if (Enabled.Value)
flashLayer.FadeOutFromOne(800, Easing.OutQuint);
return base.OnClick(e);
}
protected override bool OnHover(HoverEvent e) protected override bool OnHover(HoverEvent e)
{ {
Scheduler.AddOnce(updateState); Scheduler.AddOnce(updateState);