1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-07 16:47:24 +08:00

Merge pull request #18009 from peppy/osu-logo-drag

Allow dragging the osu! logo
This commit is contained in:
Dan Balasescu 2022-04-29 09:53:43 +09:00 committed by GitHub
commit 6652a71f48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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);
}
}
}
}