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