mirror of
https://github.com/ppy/osu.git
synced 2025-02-15 06:13:03 +08:00
Improve the feel of spinners.
This commit is contained in:
parent
7fbc5990d1
commit
31a617363a
@ -3,6 +3,7 @@
|
||||
|
||||
using System;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Transformations;
|
||||
using osu.Framework.MathUtils;
|
||||
using osu.Game.Modes.Objects.Drawables;
|
||||
@ -18,8 +19,8 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
|
||||
|
||||
private SpinnerDisc disc;
|
||||
private SpinnerBackground background;
|
||||
private Container circleContainer;
|
||||
private DrawableHitCircle circle;
|
||||
private NumberPiece number;
|
||||
|
||||
public DrawableSpinner(Spinner s) : base(s)
|
||||
{
|
||||
@ -47,16 +48,23 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
|
||||
Origin = Anchor.Centre,
|
||||
DiscColour = s.Colour
|
||||
},
|
||||
circle = new DrawableHitCircle(s)
|
||||
circleContainer = new Container
|
||||
{
|
||||
Interactive = false,
|
||||
Position = Vector2.Zero,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Children = new []
|
||||
{
|
||||
circle = new DrawableHitCircle(s)
|
||||
{
|
||||
Interactive = false,
|
||||
Position = Vector2.Zero,
|
||||
Anchor = Anchor.Centre,
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
circle.ApproachCircle.Colour = Color4.Transparent;
|
||||
|
||||
background.Scale = scaleToCircle;
|
||||
disc.Scale = scaleToCircle;
|
||||
}
|
||||
@ -71,6 +79,9 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
|
||||
|
||||
disc.ScaleTo(Interpolation.ValueAt(Math.Sqrt(Progress), scaleToCircle, Vector2.One, 0, 1), 100);
|
||||
|
||||
if (Progress >= 1)
|
||||
disc.Complete = true;
|
||||
|
||||
if (!userTriggered && Time.Current >= HitObject.EndTime)
|
||||
{
|
||||
if (Progress >= 1)
|
||||
@ -91,7 +102,8 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
|
||||
else
|
||||
{
|
||||
j.Score = OsuScoreResult.Miss;
|
||||
j.Result = HitResult.Miss;
|
||||
if (Time.Current >= HitObject.EndTime)
|
||||
j.Result = HitResult.Miss;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -109,6 +121,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
|
||||
base.UpdatePreemptState();
|
||||
|
||||
FadeIn(200);
|
||||
circleContainer.ScaleTo(1, 400, EasingTypes.OutElastic);
|
||||
|
||||
background.Delay(TIME_PREEMPT - 100);
|
||||
background.FadeIn(200);
|
||||
@ -120,12 +133,14 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
|
||||
|
||||
protected override void UpdateState(ArmedState state)
|
||||
{
|
||||
if (!IsLoaded) return;
|
||||
|
||||
base.UpdateState(state);
|
||||
|
||||
Delay(HitObject.Duration, true);
|
||||
|
||||
FadeOut(160);
|
||||
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case ArmedState.Hit:
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Colour;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
@ -10,6 +11,7 @@ using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.Transformations;
|
||||
using osu.Framework.Input;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Game.Graphics;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
|
||||
@ -27,6 +29,14 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
|
||||
set { Disc.Colour = value; }
|
||||
}
|
||||
|
||||
Color4 completeColour;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
completeColour = colours.YellowLight.Opacity(0.8f);
|
||||
}
|
||||
|
||||
class SpinnerBorder : Container
|
||||
{
|
||||
public SpinnerBorder()
|
||||
@ -120,6 +130,22 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
|
||||
}
|
||||
}
|
||||
|
||||
bool complete;
|
||||
public bool Complete
|
||||
{
|
||||
get { return complete; }
|
||||
set
|
||||
{
|
||||
if (value == complete) return;
|
||||
|
||||
complete = value;
|
||||
|
||||
Disc.FadeColour(completeColour, 200);
|
||||
|
||||
updateCompleteTick();
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
|
||||
{
|
||||
Tracking = true;
|
||||
@ -145,6 +171,10 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
|
||||
private float currentRotation;
|
||||
public float RotationAbsolute;
|
||||
|
||||
private int completeTick;
|
||||
|
||||
private bool updateCompleteTick() => completeTick != (completeTick = (int)(RotationAbsolute / 720));
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
@ -162,6 +192,14 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
|
||||
}
|
||||
lastAngle = thisAngle;
|
||||
|
||||
if (Complete && updateCompleteTick())
|
||||
{
|
||||
Disc.Flush(flushType: typeof(TransformAlpha));
|
||||
Disc.FadeTo(0.75f, 30, EasingTypes.OutExpo);
|
||||
Disc.Delay(30);
|
||||
Disc.FadeTo(0.5f, 250, EasingTypes.OutQuint);
|
||||
}
|
||||
|
||||
RotateTo(currentRotation, 100, EasingTypes.OutExpo);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user