1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 12:33:01 +08:00

Merge pull request #8213 from peppy/correct-trail-animation-frame

Fix osu!catch trail animating (and displaying incorrect frame)
This commit is contained in:
Dan Balasescu 2020-03-16 11:45:05 +09:00 committed by GitHub
commit 26c034e364
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 65 additions and 45 deletions

View File

@ -52,6 +52,6 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="ppy.osu.Game.Resources" Version="2020.315.0" />
<PackageReference Include="ppy.osu.Framework.Android" Version="2020.312.0" />
<PackageReference Include="ppy.osu.Framework.Android" Version="2020.314.0" />
</ItemGroup>
</Project>

View File

@ -7,6 +7,7 @@ using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Animations;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Input.Bindings;
using osu.Framework.Utils;
using osu.Game.Beatmaps;
@ -55,14 +56,14 @@ namespace osu.Game.Rulesets.Catch.UI
}
/// <summary>
/// Activate or deactive the trail. Will be automatically deactivated when conditions to keep the trail displayed are no longer met.
/// Activate or deactivate the trail. Will be automatically deactivated when conditions to keep the trail displayed are no longer met.
/// </summary>
protected bool Trail
{
get => trail;
set
{
if (value == trail) return;
if (value == trail || AdditiveTarget == null) return;
trail = value;
@ -77,6 +78,8 @@ namespace osu.Game.Rulesets.Catch.UI
private CatcherSprite catcherKiai;
private CatcherSprite catcherFail;
private CatcherSprite currentCatcher;
private int currentDirection;
private bool dashing;
@ -236,10 +239,10 @@ namespace osu.Game.Rulesets.Catch.UI
this.FadeTo(0.2f, hyper_dash_transition_length, Easing.OutQuint);
Trail = true;
var hyperDashEndGlow = createAdditiveSprite(true);
var hyperDashEndGlow = createAdditiveSprite();
hyperDashEndGlow.MoveToOffset(new Vector2(0, -20), 1200, Easing.In);
hyperDashEndGlow.ScaleTo(hyperDashEndGlow.Scale * 0.9f).ScaleTo(hyperDashEndGlow.Scale * 1.2f, 1200, Easing.In);
hyperDashEndGlow.MoveToOffset(new Vector2(0, -10), 1200, Easing.In);
hyperDashEndGlow.ScaleTo(hyperDashEndGlow.Scale * 0.95f).ScaleTo(hyperDashEndGlow.Scale * 1.2f, 1200, Easing.In);
hyperDashEndGlow.FadeOut(1200);
hyperDashEndGlow.Expire(true);
}
@ -358,39 +361,36 @@ namespace osu.Game.Rulesets.Catch.UI
private void updateCatcher()
{
catcherIdle.Hide();
catcherKiai.Hide();
catcherFail.Hide();
CatcherSprite current;
currentCatcher?.Hide();
switch (CurrentState)
{
default:
current = catcherIdle;
currentCatcher = catcherIdle;
break;
case CatcherAnimationState.Fail:
current = catcherFail;
currentCatcher = catcherFail;
break;
case CatcherAnimationState.Kiai:
current = catcherKiai;
currentCatcher = catcherKiai;
break;
}
current.Show();
(current.Drawable as IAnimation)?.GotoFrame(0);
currentCatcher.Show();
(currentCatcher.Drawable as IAnimation)?.GotoFrame(0);
}
private void beginTrail()
{
Trail &= dashing || HyperDashing;
Trail &= AdditiveTarget != null;
if (!dashing && !HyperDashing)
{
Trail = false;
return;
}
if (!Trail) return;
var additive = createAdditiveSprite(HyperDashing);
var additive = createAdditiveSprite();
additive.FadeTo(0.4f).FadeOut(800, Easing.OutQuint);
additive.Expire(true);
@ -398,27 +398,6 @@ namespace osu.Game.Rulesets.Catch.UI
Scheduler.AddDelayed(beginTrail, HyperDashing ? 25 : 50);
}
private Drawable createAdditiveSprite(bool hyperDash)
{
var additive = createCatcherSprite();
additive.Anchor = Anchor;
additive.Scale = Scale;
additive.Colour = hyperDash ? Color4.Red : Color4.White;
additive.Blending = BlendingParameters.Additive;
additive.RelativePositionAxes = RelativePositionAxes;
additive.Position = Position;
AdditiveTarget.Add(additive);
return additive;
}
private Drawable createCatcherSprite()
{
return new CatcherSprite(CurrentState);
}
private void updateState(CatcherAnimationState state)
{
if (CurrentState == state)
@ -428,6 +407,25 @@ namespace osu.Game.Rulesets.Catch.UI
updateCatcher();
}
private CatcherTrailSprite createAdditiveSprite()
{
var tex = (currentCatcher.Drawable as TextureAnimation)?.CurrentFrame ?? ((Sprite)currentCatcher.Drawable).Texture;
var sprite = new CatcherTrailSprite(tex)
{
Anchor = Anchor,
Scale = Scale,
Colour = HyperDashing ? Color4.Red : Color4.White,
Blending = BlendingParameters.Additive,
RelativePositionAxes = RelativePositionAxes,
Position = Position
};
AdditiveTarget?.Add(sprite);
return sprite;
}
private void removeFromPlateWithTransform(DrawableHitObject fruit, Action<DrawableHitObject> action)
{
if (ExplodingFruitTarget != null)

View File

@ -0,0 +1,22 @@
// 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.
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osuTK;
namespace osu.Game.Rulesets.Catch.UI
{
public class CatcherTrailSprite : Sprite
{
public CatcherTrailSprite(Texture texture)
{
Texture = texture;
Size = new Vector2(CatcherArea.CATCHER_SIZE);
// Sets the origin roughly to the centre of the catcher's plate to allow for correct scaling.
OriginPosition = new Vector2(0.5f, 0.06f) * CatcherArea.CATCHER_SIZE;
}
}
}

View File

@ -23,7 +23,7 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2020.315.0" />
<PackageReference Include="ppy.osu.Framework" Version="2020.312.0" />
<PackageReference Include="ppy.osu.Framework" Version="2020.314.0" />
<PackageReference Include="Sentry" Version="2.1.0" />
<PackageReference Include="SharpCompress" Version="0.24.0" />
<PackageReference Include="NUnit" Version="3.12.0" />

View File

@ -71,7 +71,7 @@
</ItemGroup>
<ItemGroup Label="Package References">
<PackageReference Include="ppy.osu.Game.Resources" Version="2020.315.0" />
<PackageReference Include="ppy.osu.Framework.iOS" Version="2020.312.0" />
<PackageReference Include="ppy.osu.Framework.iOS" Version="2020.314.0" />
</ItemGroup>
<!-- Xamarin.iOS does not automatically handle transitive dependencies from NuGet packages. -->
<ItemGroup Label="Transitive Dependencies">
@ -79,7 +79,7 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="ppy.osu.Framework" Version="2020.312.0" />
<PackageReference Include="ppy.osu.Framework" Version="2020.314.0" />
<PackageReference Include="SharpCompress" Version="0.24.0" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="SharpRaven" Version="2.4.0" />