mirror of
https://github.com/ppy/osu.git
synced 2025-02-20 16:12:54 +08:00
Fixed some animations
This commit is contained in:
parent
fa67ab86ed
commit
e9a38f0c4d
@ -42,11 +42,11 @@ namespace osu.Desktop.Tests
|
||||
{
|
||||
Origin = Anchor.BottomLeft,
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Position = new Vector2(20, 20),
|
||||
Position = new Vector2(10, 10),
|
||||
InnerCountPosition = new Vector2(10, 10),
|
||||
IsRollingProportional = true,
|
||||
RollingDuration = 20,
|
||||
PopOutDuration = 3000,
|
||||
PopOutDuration = 100,
|
||||
Count = 0,
|
||||
TextSize = 40,
|
||||
};
|
||||
|
@ -52,7 +52,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
removeTransforms(typeof(TransformULongCounter));
|
||||
VisibleCount = newValue;
|
||||
}
|
||||
else
|
||||
else if (currentValue != 0)
|
||||
transformCount(new TransformULongCounter(Clock), currentValue, newValue);
|
||||
}
|
||||
|
||||
@ -62,7 +62,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
return difference * RollingDuration;
|
||||
}
|
||||
|
||||
protected virtual void transformAnimate()
|
||||
protected virtual void transformAnimate(ulong newValue)
|
||||
{
|
||||
countSpriteText.FadeColour(TintColour, 0);
|
||||
countSpriteText.ScaleTo(new Vector2(1, ScaleFactor));
|
||||
@ -72,20 +72,15 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
protected override void transformVisibleCount(ulong currentValue, ulong newValue)
|
||||
{
|
||||
if (countSpriteText != null)
|
||||
{
|
||||
countSpriteText.Text = newValue.ToString("#,0");
|
||||
if (newValue == 0)
|
||||
{
|
||||
countSpriteText.FadeOut(TintDuration);
|
||||
return;
|
||||
}
|
||||
countSpriteText.Text = formatCount(newValue);
|
||||
|
||||
if (newValue == 0)
|
||||
countSpriteText.FadeOut(TintDuration);
|
||||
else
|
||||
countSpriteText.Show();
|
||||
if (newValue > currentValue || CanAnimateWhenBackwards)
|
||||
{
|
||||
transformAnimate();
|
||||
}
|
||||
}
|
||||
|
||||
if (newValue > currentValue || CanAnimateWhenBackwards)
|
||||
transformAnimate(newValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
removeTransforms(typeof(TransformULongCounter));
|
||||
VisibleCount = newValue;
|
||||
}
|
||||
else
|
||||
else if (currentValue != 0)
|
||||
{
|
||||
// Backwards pop-up animation has no tint colour
|
||||
popOutSpriteText.Colour = countSpriteText.Colour;
|
||||
|
@ -20,7 +20,9 @@ namespace osu.Game.Graphics.UserInterface
|
||||
/// </summary>
|
||||
public class StandardComboCounter : ULongCounter
|
||||
{
|
||||
public SpriteText popOutSpriteText;
|
||||
protected SpriteText popOutSpriteText;
|
||||
|
||||
protected volatile int scheduledPopOutCurrentId = 0;
|
||||
|
||||
public ulong PopOutDuration = 0;
|
||||
public float PopOutBigScale = 2.0f;
|
||||
@ -82,7 +84,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
removeTransforms(typeof(TransformULongCounter));
|
||||
VisibleCount = newValue;
|
||||
}
|
||||
else
|
||||
else if (currentValue != 0)
|
||||
transformCount(new TransformULongCounter(Clock), currentValue, newValue);
|
||||
}
|
||||
|
||||
@ -97,55 +99,61 @@ namespace osu.Game.Graphics.UserInterface
|
||||
return count.ToString("#,0") + "x";
|
||||
}
|
||||
|
||||
protected virtual void transformPopOut(ulong newValue)
|
||||
protected virtual void transformPopOut(ulong currentValue, ulong newValue)
|
||||
{
|
||||
popOutSpriteText.Text = formatCount(newValue);
|
||||
countSpriteText.Text = formatCount(currentValue);
|
||||
|
||||
popOutSpriteText.ScaleTo(PopOutBigScale);
|
||||
popOutSpriteText.FadeTo(PopOutInitialAlpha);
|
||||
popOutSpriteText.Position = Vector2.Zero;
|
||||
popOutSpriteText.MoveTo(Vector2.Zero);
|
||||
|
||||
popOutSpriteText.ScaleTo(1, PopOutDuration, PopOutEasing);
|
||||
popOutSpriteText.FadeOut(PopOutDuration, PopOutEasing);
|
||||
popOutSpriteText.MoveTo(countSpriteText.Position, PopOutDuration, PopOutEasing);
|
||||
|
||||
scheduledPopOutCurrentId++;
|
||||
int newTaskId = scheduledPopOutCurrentId;
|
||||
Scheduler.AddDelayed(delegate
|
||||
{
|
||||
transformPopOutNew(newValue);
|
||||
scheduledPopOutSmall(newTaskId, newValue);
|
||||
}, PopOutDuration);
|
||||
}
|
||||
|
||||
protected virtual void transformPopOutNew(ulong newValue)
|
||||
{
|
||||
// Too late; scheduled task invalidated
|
||||
if (newValue != VisibleCount)
|
||||
return;
|
||||
protected virtual void transformNoPopOut(ulong newValue)
|
||||
{
|
||||
scheduledPopOutCurrentId++;
|
||||
countSpriteText.Text = formatCount(newValue);
|
||||
countSpriteText.ScaleTo(1);
|
||||
}
|
||||
|
||||
protected virtual void transformPopOutSmall(ulong newValue)
|
||||
{
|
||||
countSpriteText.Text = formatCount(newValue);
|
||||
countSpriteText.ScaleTo(PopOutSmallScale);
|
||||
countSpriteText.ScaleTo(1, PopOutDuration, PopOutEasing);
|
||||
}
|
||||
|
||||
protected virtual void scheduledPopOutSmall(int id, ulong newValue)
|
||||
{
|
||||
// Too late; scheduled task invalidated
|
||||
if (id != scheduledPopOutCurrentId)
|
||||
return;
|
||||
|
||||
transformPopOutSmall(newValue);
|
||||
}
|
||||
|
||||
protected override void transformVisibleCount(ulong currentValue, ulong newValue)
|
||||
{
|
||||
popOutSpriteText.Text = formatCount(newValue);
|
||||
if (newValue > currentValue)
|
||||
{
|
||||
countSpriteText.Text = formatCount(newValue - 1);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
countSpriteText.Text = formatCount(newValue);
|
||||
}
|
||||
if (newValue == 0)
|
||||
{
|
||||
countSpriteText.FadeOut(PopOutDuration);
|
||||
}
|
||||
else
|
||||
{
|
||||
countSpriteText.Show();
|
||||
if (newValue > currentValue || CanPopOutWhenBackwards)
|
||||
transformPopOut(newValue);
|
||||
}
|
||||
|
||||
if (newValue > currentValue || CanPopOutWhenBackwards)
|
||||
transformPopOut(currentValue, newValue);
|
||||
else
|
||||
transformNoPopOut(newValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user