mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 15:47:26 +08:00
Randomise direction every animation playback
This commit is contained in:
parent
9d04ce75cc
commit
efd5acb8ab
@ -20,7 +20,7 @@ namespace osu.Game.Graphics
|
|||||||
{
|
{
|
||||||
double rDuration = RNG.NextDouble(duration / 3, duration);
|
double rDuration = RNG.NextDouble(duration / 3, duration);
|
||||||
|
|
||||||
AddInternal(new Particle(rDuration, RNG.NextSingle(0, MathF.PI * 2))
|
AddInternal(new Particle(rDuration)
|
||||||
{
|
{
|
||||||
Texture = texture
|
Texture = texture
|
||||||
});
|
});
|
||||||
@ -36,19 +36,12 @@ namespace osu.Game.Graphics
|
|||||||
private class Particle : Sprite
|
private class Particle : Sprite
|
||||||
{
|
{
|
||||||
private readonly double duration;
|
private readonly double duration;
|
||||||
private readonly float direction;
|
|
||||||
|
|
||||||
public override bool RemoveWhenNotAlive => false;
|
public override bool RemoveWhenNotAlive => false;
|
||||||
|
|
||||||
private Vector2 positionForOffset(float offset) => new Vector2(
|
public Particle(double duration)
|
||||||
(float)(offset * Math.Sin(direction)),
|
|
||||||
(float)(offset * Math.Cos(direction))
|
|
||||||
);
|
|
||||||
|
|
||||||
public Particle(double duration, float direction)
|
|
||||||
{
|
{
|
||||||
this.duration = duration;
|
this.duration = duration;
|
||||||
this.direction = direction;
|
|
||||||
|
|
||||||
Origin = Anchor.Centre;
|
Origin = Anchor.Centre;
|
||||||
Blending = BlendingParameters.Additive;
|
Blending = BlendingParameters.Additive;
|
||||||
@ -64,11 +57,18 @@ namespace osu.Game.Graphics
|
|||||||
|
|
||||||
public void Play()
|
public void Play()
|
||||||
{
|
{
|
||||||
|
double direction = RNG.NextSingle(0, MathF.PI * 2);
|
||||||
|
|
||||||
this.MoveTo(new Vector2(0.5f));
|
this.MoveTo(new Vector2(0.5f));
|
||||||
this.MoveTo(new Vector2(0.5f) + positionForOffset(0.5f), duration);
|
this.MoveTo(new Vector2(0.5f) + positionForOffset(0.5f), duration);
|
||||||
|
|
||||||
this.FadeOutFromOne(duration);
|
this.FadeOutFromOne(duration);
|
||||||
Expire();
|
Expire();
|
||||||
|
|
||||||
|
Vector2 positionForOffset(float offset) => new Vector2(
|
||||||
|
(float)(offset * Math.Sin(direction)),
|
||||||
|
(float)(offset * Math.Cos(direction))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user