mirror of
https://github.com/ppy/osu.git
synced 2024-11-07 18:47:26 +08:00
Merge pull request #18009 from peppy/osu-logo-drag
Allow dragging the osu! logo
This commit is contained in:
commit
6652a71f48
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user