mirror of
https://github.com/ppy/osu.git
synced 2025-01-14 04:02:59 +08:00
Fix spinners playing looping sound too long in the editor
The `OnComplete` event was never being run due to the transform playing out longer than the spinner's lifetime. I've matched the durations, but also moved the `Stop()` call to what I deem a safer place to run it (I did notice that without this it would still potentially never fire). Note that this is more noticeable in the editor because of lifetime extension. In gameplay, the returning of a spinner to the pool will clean things up (but in the editor that can take longer, depending on timeline zoom level). Another thing worth mentioning is that the fade doesn't actually work. This is due to https://github.com/ppy/osu-framework/pull/4212. Closes #12119.
This commit is contained in:
parent
7034289763
commit
c4d08463ad
@ -39,6 +39,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
||||
private Bindable<bool> isSpinning;
|
||||
private bool spinnerFrequencyModulate;
|
||||
|
||||
private const double fade_out_duration = 160;
|
||||
|
||||
public DrawableSpinner()
|
||||
: this(null)
|
||||
{
|
||||
@ -136,7 +138,10 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
||||
}
|
||||
else
|
||||
{
|
||||
spinningSample?.VolumeTo(0, 300).OnComplete(_ => spinningSample.Stop());
|
||||
if (spinningSample != null)
|
||||
spinningSample.Volume.Value = 0;
|
||||
|
||||
spinningSample?.VolumeTo(0, fade_out_duration);
|
||||
}
|
||||
}
|
||||
|
||||
@ -173,7 +178,14 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
||||
{
|
||||
base.UpdateHitStateTransforms(state);
|
||||
|
||||
this.FadeOut(160).Expire();
|
||||
this.FadeOut(fade_out_duration).OnComplete(_ =>
|
||||
{
|
||||
// looping sample should be stopped here as it is safer than running in the OnComplete
|
||||
// of the volume transition above.
|
||||
spinningSample.Stop();
|
||||
});
|
||||
|
||||
Expire();
|
||||
|
||||
// skin change does a rewind of transforms, which will stop the spinning sound from playing if it's currently in playback.
|
||||
isSpinning?.TriggerChange();
|
||||
|
Loading…
Reference in New Issue
Block a user