mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 12:57:36 +08:00
Change from click to mousedown+mouseup and only play when cursor is visible
This commit is contained in:
parent
4d9b61212b
commit
6e60e68b80
@ -76,18 +76,6 @@ namespace osu.Game.Graphics.Cursor
|
||||
return base.OnMouseMove(e);
|
||||
}
|
||||
|
||||
protected override bool OnClick(ClickEvent e)
|
||||
{
|
||||
var channel = tapSample.GetChannel();
|
||||
|
||||
// scale to [-0.75, 0.75] so that the sample isn't fully panned left or right (sounds weird)
|
||||
channel.Balance.Value = ((activeCursor.X / DrawWidth) * 2 - 1) * 0.75;
|
||||
channel.Frequency.Value = 0.99 + RNG.NextDouble(0.02);
|
||||
channel.Play();
|
||||
|
||||
return base.OnClick(e);
|
||||
}
|
||||
|
||||
protected override bool OnMouseDown(MouseDownEvent e)
|
||||
{
|
||||
if (State.Value == Visibility.Visible)
|
||||
@ -105,6 +93,8 @@ namespace osu.Game.Graphics.Cursor
|
||||
dragRotationState = DragRotationState.DragStarted;
|
||||
positionMouseDown = e.MousePosition;
|
||||
}
|
||||
|
||||
playTapSample();
|
||||
}
|
||||
|
||||
return base.OnMouseDown(e);
|
||||
@ -122,6 +112,9 @@ namespace osu.Game.Graphics.Cursor
|
||||
activeCursor.RotateTo(0, 600 * (1 + Math.Abs(activeCursor.Rotation / 720)), Easing.OutElasticHalf);
|
||||
dragRotationState = DragRotationState.NotDragging;
|
||||
}
|
||||
|
||||
if (State.Value == Visibility.Visible)
|
||||
playTapSample(0.8);
|
||||
}
|
||||
|
||||
base.OnMouseUp(e);
|
||||
@ -139,6 +132,18 @@ namespace osu.Game.Graphics.Cursor
|
||||
activeCursor.ScaleTo(0.6f, 250, Easing.In);
|
||||
}
|
||||
|
||||
private void playTapSample(double baseFrequency = 1f)
|
||||
{
|
||||
const float random_range = 0.02f;
|
||||
SampleChannel channel = tapSample.GetChannel();
|
||||
|
||||
// Scale to [-0.75, 0.75] so that the sample isn't fully panned left or right (sounds weird)
|
||||
channel.Balance.Value = ((activeCursor.X / DrawWidth) * 2 - 1) * 0.75;
|
||||
channel.Frequency.Value = baseFrequency - (random_range / 2f) + RNG.NextDouble(random_range);
|
||||
|
||||
channel.Play();
|
||||
}
|
||||
|
||||
public class Cursor : Container
|
||||
{
|
||||
private Container cursorContainer;
|
||||
|
Loading…
Reference in New Issue
Block a user