1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 06:17:23 +08:00

Add basic beat response to osu! logo

This commit is contained in:
Dean Herbert 2017-05-23 12:29:43 +09:00
parent d1eb8937b7
commit 3e0aaa1aa0
2 changed files with 106 additions and 76 deletions

View File

@ -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);

View File

@ -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;
@ -78,109 +85,116 @@ namespace osu.Game.Screens.Menu
Children = new Drawable[]
{
logoBounceContainer = new Container
logoBeatContainer = new Container
{
AutoSizeAxes = Axes.Both,
Children = new Drawable[]
{
logoHoverContainer = new Container
logoBounceContainer = new Container
{
AutoSizeAxes = Axes.Both,
Children = new Drawable[]
{
new BufferedContainer
logoHoverContainer = new Container
{
AutoSizeAxes = Axes.Both,
Children = new Drawable[]
{
logoContainer = new CircularContainer
new BufferedContainer
{
AutoSizeAxes = Axes.Both,
Children = new Drawable[]
{
logoContainer = new CircularContainer
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
Scale = new Vector2(0.88f),
Masking = true,
Children = new Drawable[]
{
colourAndTriangles = new Container
{
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = OsuPink,
},
new Triangles
{
TriangleScale = 4,
ColourLight = OsuColour.FromHex(@"ff7db7"),
ColourDark = OsuColour.FromHex(@"de5b95"),
RelativeSizeAxes = Axes.Both,
},
}
},
flashLayer = new Box
{
RelativeSizeAxes = Axes.Both,
BlendingMode = BlendingMode.Additive,
Colour = Color4.White,
Alpha = 0,
},
},
},
logo = new Sprite
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
},
}
},
rippleContainer = new Container
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
Scale = new Vector2(0.88f),
Children = new Drawable[]
{
ripple = new Sprite
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
BlendingMode = BlendingMode.Additive,
Alpha = 0.15f
}
}
},
impactContainer = new CircularContainer
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Alpha = 0,
BorderColour = Color4.White,
RelativeSizeAxes = Axes.Both,
BorderThickness = 10,
Masking = true,
Children = new Drawable[]
{
colourAndTriangles = new Container
new Box
{
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = OsuPink,
},
new Triangles
{
TriangleScale = 4,
ColourLight = OsuColour.FromHex(@"ff7db7"),
ColourDark = OsuColour.FromHex(@"de5b95"),
RelativeSizeAxes = Axes.Both,
},
}
},
flashLayer = new Box
{
RelativeSizeAxes = Axes.Both,
BlendingMode = BlendingMode.Additive,
Colour = Color4.White,
AlwaysPresent = true,
Alpha = 0,
},
},
}
}
},
logo = new Sprite
new MenuVisualisation
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
},
}
},
rippleContainer = new Container
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
Children = new Drawable[]
{
ripple = new Sprite
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
BlendingMode = BlendingMode.Additive,
Alpha = 0.15f
}
}
},
impactContainer = new CircularContainer
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Alpha = 0,
BorderColour = Color4.White,
RelativeSizeAxes = Axes.Both,
BorderThickness = 10,
Masking = true,
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
AlwaysPresent = true,
Alpha = 0,
BlendingMode = BlendingMode.Additive,
Alpha = 0.2f,
}
}
},
new MenuVisualisation
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
BlendingMode = BlendingMode.Additive,
Alpha = 0.2f,
}
}
}
@ -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;