1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 13:37:25 +08:00

Add "spin" sprite

This commit is contained in:
Dean Herbert 2020-11-05 18:12:13 +09:00
parent 5ec6011340
commit 3ec813da03

View File

@ -1,11 +1,14 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using System;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Osu.Objects.Drawables; using osu.Game.Rulesets.Osu.Objects.Drawables;
using osu.Game.Skinning;
namespace osu.Game.Rulesets.Osu.Skinning namespace osu.Game.Rulesets.Osu.Skinning
{ {
@ -13,12 +16,26 @@ namespace osu.Game.Rulesets.Osu.Skinning
{ {
protected DrawableSpinner DrawableSpinner { get; private set; } protected DrawableSpinner DrawableSpinner { get; private set; }
private Sprite spin;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(DrawableHitObject drawableHitObject) private void load(DrawableHitObject drawableHitObject, ISkinSource source)
{ {
RelativeSizeAxes = Axes.Both; RelativeSizeAxes = Axes.Both;
DrawableSpinner = (DrawableSpinner)drawableHitObject; DrawableSpinner = (DrawableSpinner)drawableHitObject;
AddRangeInternal(new[]
{
spin = new Sprite
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Depth = float.MinValue,
Texture = source.GetTexture("spinner-spin"),
Y = 120 // todo: make match roughly?
},
});
} }
protected override void LoadComplete() protected override void LoadComplete()
@ -31,6 +48,25 @@ namespace osu.Game.Rulesets.Osu.Skinning
protected virtual void UpdateStateTransforms(DrawableHitObject drawableHitObject, ArmedState state) protected virtual void UpdateStateTransforms(DrawableHitObject drawableHitObject, ArmedState state)
{ {
switch (drawableHitObject)
{
case DrawableSpinner d:
double fadeOutLength = Math.Min(400, d.HitObject.Duration);
using (BeginAbsoluteSequence(drawableHitObject.HitStateUpdateTime - fadeOutLength, true))
spin.FadeOutFromOne(fadeOutLength);
break;
case DrawableSpinnerTick d:
if (state == ArmedState.Hit)
{
using (BeginAbsoluteSequence(d.HitStateUpdateTime, true))
spin.FadeOut(300);
}
break;
}
} }
protected override void Dispose(bool isDisposing) protected override void Dispose(bool isDisposing)