Allow dragging the osu! logo

Logic borrowed from `NowPlayingOverlay`.
This commit is contained in:
Dean Herbert 2022-04-28 22:58:32 +09:00
parent 899e40dff7
commit 32ad216669

View File

@ -109,7 +109,7 @@ namespace osu.Game.Screens.Menu
AutoSizeAxes = Axes.Both,
Children = new Drawable[]
{
logoBounceContainer = new Container
logoBounceContainer = new DragContainer
{
AutoSizeAxes = Axes.Both,
Children = new Drawable[]
@ -402,5 +402,26 @@ namespace osu.Game.Screens.Menu
impactContainer.ScaleTo(0.96f);
impactContainer.ScaleTo(1.12f, 250);
}
private class DragContainer : Container
{
protected override bool OnDragStart(DragStartEvent e) => true;
protected override void OnDrag(DragEvent e)
{
Vector2 change = e.MousePosition - e.MouseDownPosition;
// Diminish the drag distance as we go further to simulate "rubber band" feeling.
change *= change.Length <= 0 ? 0 : MathF.Pow(change.Length, 0.6f) / change.Length;
this.MoveTo(change);
}
protected override void OnDragEnd(DragEndEvent e)
{
this.MoveTo(Vector2.Zero, 800, Easing.OutElastic);
base.OnDragEnd(e);
}
}
}
}