1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-27 03:23:03 +08:00

Add fades

This commit is contained in:
smoogipoo 2020-08-26 20:46:12 +09:00
parent 6fe1279e9d
commit 157e1d8965

View File

@ -59,7 +59,13 @@ namespace osu.Game.Rulesets.Mania.Skinning
}); });
if (light != null) if (light != null)
lightContainer = new HitTargetInsetContainer { Child = light }; {
lightContainer = new HitTargetInsetContainer
{
Alpha = 0,
Child = light
};
}
bodySprite = skin.GetAnimation(imageName, WrapMode.ClampToEdge, WrapMode.ClampToEdge, true, true).With(d => bodySprite = skin.GetAnimation(imageName, WrapMode.ClampToEdge, WrapMode.ClampToEdge, true, true).With(d =>
{ {
@ -99,14 +105,24 @@ namespace osu.Game.Rulesets.Mania.Skinning
{ {
if (isHitting.NewValue) if (isHitting.NewValue)
{ {
Column.TopLevelContainer.Add(lightContainer); // Clear the fade out and, more importantly, the removal.
lightContainer.ClearTransforms();
// The light must be seeked only after being loaded, otherwise a nullref happens (https://github.com/ppy/osu-framework/issues/3847). // Only add the container if the removal has taken place.
if (lightContainer.Parent == null)
Column.TopLevelContainer.Add(lightContainer);
// The light must be seeked only after being loaded, otherwise a nullref occurs (https://github.com/ppy/osu-framework/issues/3847).
if (light is TextureAnimation lightAnimation) if (light is TextureAnimation lightAnimation)
lightAnimation.GotoFrame(0); lightAnimation.GotoFrame(0);
lightContainer.FadeIn(80);
} }
else else
Column.TopLevelContainer.Remove(lightContainer); {
lightContainer.FadeOut(120)
.OnComplete(d => Column.TopLevelContainer.Remove(d));
}
} }
} }