Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the Fade-In effect to DrawableSwell #31722

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableHit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@
using System;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
using JetBrains.Annotations;
using Microsoft.Extensions.Logging;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Input.Events;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.Taiko.Skinning.Default;
using osu.Game.Rulesets.Taiko.UI;
using osu.Game.Skinning;
using osuTK;

Expand All @@ -38,6 +42,21 @@ public TaikoAction? HitAction

private double? lastPressHandleTime;

/// <summary>
/// Duration of the Fade-In time of the hit.
/// </summary>
private const double fade_in_duration = 5000;

/// <summary>
/// Opacity difference of fade-in effect between scroll speeds.
/// </summary>
private const double fade_in_curve_factor = 200;

/// <summary>
/// Minimum time between HitObject.StartTime and LifetimeStart.
/// </summary>
private const double min_start_time_delta = 90;

private readonly Bindable<HitType> type = new Bindable<HitType>();

public DrawableHit()
Expand Down Expand Up @@ -142,6 +161,19 @@ public override void OnReleased(KeyBindingReleaseEvent<TaikoAction> e)
base.OnReleased(e);
}

protected override void UpdateInitialTransforms()
{
double start_time_delta = HitObject.StartTime - LifetimeStart;
// scale Alpha value to adjust to stable's fade-in object opacity when LifetimeStart begins, being the first accessible time point in which changing Alpha is possible
Alpha = (float)(1d - Math.Exp(-(start_time_delta - min_start_time_delta) / fade_in_curve_factor));

using (BeginAbsoluteSequence(LifetimeStart))
{
// makes the fade-in effect negligible on low enough scroll speeds
this.FadeIn(fade_in_duration * (1 - Alpha));
}
}

protected override void UpdateHitStateTransforms(ArmedState state)
{
Debug.Assert(HitObject.HitWindows != null);
Expand Down
19 changes: 19 additions & 0 deletions osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableSwell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ public partial class DrawableSwell : DrawableTaikoHitObject<Swell>
/// </summary>
private const double ring_appear_offset = 100;

/// <summary>
/// Offset away from the start time of the swell at which the Fade-In effect starts.
/// </summary>
private const double fade_in_offset = 1833;
/// <summary>
/// Duration of the Fade-In time of the swell.
/// </summary>
private const double fade_in_duration = 666;

private Vector2 baseSize;

private readonly Container<DrawableSwellTick> ticks;
Expand Down Expand Up @@ -248,10 +257,20 @@ protected override void CheckForResult(bool userTriggered, double timeOffset)
}
}

protected override void UpdateInitialTransforms()
{
// allow for the fade-in effect
Alpha = 0;
}

protected override void UpdateStartTimeStateTransforms()
{
base.UpdateStartTimeStateTransforms();

// swell fade-in effect from stable
using (BeginDelayedSequence(-fade_in_offset))
this.FadeIn(fade_in_duration, Easing.In);

using (BeginDelayedSequence(-ring_appear_offset))
targetRing.ScaleTo(target_ring_scale, 400, Easing.OutQuint);
}
Expand Down