1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-13 07:22:54 +08:00

Adjusted Combo Counter animation

This commit is contained in:
Adonais Romero González 2016-10-12 15:28:24 -05:00
parent 11e0429fd3
commit fa67ab86ed
2 changed files with 50 additions and 10 deletions

View File

@ -43,9 +43,10 @@ namespace osu.Desktop.Tests
Origin = Anchor.BottomLeft, Origin = Anchor.BottomLeft,
Anchor = Anchor.BottomLeft, Anchor = Anchor.BottomLeft,
Position = new Vector2(20, 20), Position = new Vector2(20, 20),
InnerCountPosition = new Vector2(10, 10),
IsRollingProportional = true, IsRollingProportional = true,
RollingDuration = 20, RollingDuration = 20,
PopOutDuration = 250, PopOutDuration = 3000,
Count = 0, Count = 0,
TextSize = 40, TextSize = 40,
}; };
@ -57,7 +58,7 @@ namespace osu.Desktop.Tests
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
IsRollingProportional = true, IsRollingProportional = true,
RollingDuration = 20, RollingDuration = 20,
PopOutDuration = 250, PopOutDuration = 100,
Count = 0, Count = 0,
TextSize = 40, TextSize = 40,
}; };

View File

@ -1,9 +1,12 @@
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>. //Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE //Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using OpenTK;
using osu.Framework; using osu.Framework;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Transformations; using osu.Framework.Graphics.Transformations;
using osu.Framework.Timing;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -21,11 +24,23 @@ namespace osu.Game.Graphics.UserInterface
public ulong PopOutDuration = 0; public ulong PopOutDuration = 0;
public float PopOutBigScale = 2.0f; public float PopOutBigScale = 2.0f;
public float PopOutSmallScale = 1.2f; public float PopOutSmallScale = 1.1f;
public EasingTypes PopOutEasing = EasingTypes.None; public EasingTypes PopOutEasing = EasingTypes.None;
public bool CanPopOutWhenBackwards = false; public bool CanPopOutWhenBackwards = false;
public float PopOutInitialAlpha = 0.75f; public float PopOutInitialAlpha = 0.75f;
public Vector2 InnerCountPosition
{
get
{
return countSpriteText.Position;
}
set
{
countSpriteText.Position = value;
}
}
public StandardComboCounter() : base() public StandardComboCounter() : base()
{ {
IsRollingContinuous = false; IsRollingContinuous = false;
@ -58,7 +73,6 @@ namespace osu.Game.Graphics.UserInterface
popOutSpriteText.TextSize = this.TextSize; popOutSpriteText.TextSize = this.TextSize;
} }
protected override void transformCount(ulong currentValue, ulong newValue) protected override void transformCount(ulong currentValue, ulong newValue)
{ {
// Animate rollover only when going backwards // Animate rollover only when going backwards
@ -83,20 +97,45 @@ namespace osu.Game.Graphics.UserInterface
return count.ToString("#,0") + "x"; return count.ToString("#,0") + "x";
} }
protected virtual void transformPopOut() protected virtual void transformPopOut(ulong newValue)
{ {
countSpriteText.ScaleTo(PopOutSmallScale);
countSpriteText.ScaleTo(1, PopOutDuration, PopOutEasing);
popOutSpriteText.ScaleTo(PopOutBigScale); popOutSpriteText.ScaleTo(PopOutBigScale);
popOutSpriteText.FadeTo(PopOutInitialAlpha); popOutSpriteText.FadeTo(PopOutInitialAlpha);
popOutSpriteText.Position = 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);
Scheduler.AddDelayed(delegate
{
transformPopOutNew(newValue);
}, PopOutDuration);
}
protected virtual void transformPopOutNew(ulong newValue)
{
// Too late; scheduled task invalidated
if (newValue != VisibleCount)
return;
countSpriteText.Text = formatCount(newValue);
countSpriteText.ScaleTo(PopOutSmallScale);
countSpriteText.ScaleTo(1, PopOutDuration, PopOutEasing);
} }
protected override void transformVisibleCount(ulong currentValue, ulong newValue) protected override void transformVisibleCount(ulong currentValue, ulong newValue)
{ {
countSpriteText.Text = popOutSpriteText.Text = formatCount(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);
@ -105,7 +144,7 @@ namespace osu.Game.Graphics.UserInterface
{ {
countSpriteText.Show(); countSpriteText.Show();
if (newValue > currentValue || CanPopOutWhenBackwards) if (newValue > currentValue || CanPopOutWhenBackwards)
transformPopOut(); transformPopOut(newValue);
} }
} }
} }