mirror of
https://github.com/ppy/osu.git
synced 2025-01-14 20:03:21 +08:00
Add basic beat response to osu! logo
This commit is contained in:
parent
d1eb8937b7
commit
3e0aaa1aa0
@ -16,12 +16,19 @@ namespace osu.Game.Graphics.Containers
|
||||
private int lastBeat;
|
||||
private ControlPoint lastControlPoint;
|
||||
|
||||
/// <summary>
|
||||
/// The amount of time before a beat we should fire <see cref="OnNewBeat(int, double, TimeSignatures, bool)"/>.
|
||||
/// This allows for adding easing to animations that may be synchronised to the beat.
|
||||
/// </summary>
|
||||
protected double EarlyActivationMilliseconds;
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
if (beatmap.Value?.Track == null)
|
||||
return;
|
||||
|
||||
double currentTrackTime = beatmap.Value.Track.CurrentTime;
|
||||
double currentTrackTime = beatmap.Value.Track.CurrentTime + EarlyActivationMilliseconds;
|
||||
|
||||
ControlPoint overridePoint;
|
||||
ControlPoint controlPoint = beatmap.Value.Beatmap.TimingInfo.TimingPointAt(currentTrackTime, out overridePoint);
|
||||
|
||||
|
@ -12,21 +12,24 @@ using osu.Framework.Graphics.Textures;
|
||||
using osu.Framework.Input;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Backgrounds;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Game.Beatmaps.Timing;
|
||||
|
||||
namespace osu.Game.Screens.Menu
|
||||
{
|
||||
/// <summary>
|
||||
/// osu! logo and its attachments (pulsing, visualiser etc.)
|
||||
/// </summary>
|
||||
public class OsuLogo : Container
|
||||
public class OsuLogo : BeatSyncedContainer
|
||||
{
|
||||
public readonly Color4 OsuPink = OsuColour.FromHex(@"e967a1");
|
||||
|
||||
private readonly Sprite logo;
|
||||
private readonly CircularContainer logoContainer;
|
||||
private readonly Container logoBounceContainer;
|
||||
private readonly Container logoBeatContainer;
|
||||
private readonly Container logoHoverContainer;
|
||||
|
||||
private SampleChannel sampleClick;
|
||||
@ -67,8 +70,12 @@ namespace osu.Game.Screens.Menu
|
||||
|
||||
private const float default_size = 480;
|
||||
|
||||
private const double beat_in_time = 60;
|
||||
|
||||
public OsuLogo()
|
||||
{
|
||||
EarlyActivationMilliseconds = beat_in_time;
|
||||
|
||||
Size = new Vector2(default_size);
|
||||
|
||||
Anchor = Anchor.Centre;
|
||||
@ -76,6 +83,11 @@ namespace osu.Game.Screens.Menu
|
||||
|
||||
AutoSizeAxes = Axes.Both;
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
logoBeatContainer = new Container
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
logoBounceContainer = new Container
|
||||
@ -186,6 +198,8 @@ namespace osu.Game.Screens.Menu
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -206,6 +220,15 @@ namespace osu.Game.Screens.Menu
|
||||
ripple.Loop(300);
|
||||
}
|
||||
|
||||
protected override void OnNewBeat(int newBeat, double beatLength, TimeSignatures timeSignature, bool kiai)
|
||||
{
|
||||
base.OnNewBeat(newBeat, beatLength, timeSignature, kiai);
|
||||
|
||||
logoBeatContainer.ScaleTo(0.97f, beat_in_time, EasingTypes.Out);
|
||||
using (logoBeatContainer.BeginDelayedSequence(beat_in_time))
|
||||
logoBeatContainer.ScaleTo(1, beatLength * 2, EasingTypes.OutQuint);
|
||||
}
|
||||
|
||||
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
|
||||
{
|
||||
if (!Interactive) return false;
|
||||
|
Loading…
Reference in New Issue
Block a user