示例#1
0
        public override void Start(Timeline t, Vector2 origin, Vector2 impulse)
        {
            base.Start(t, origin, impulse);

            var size = (Rand.Between(.05f, .1f) * Force).Clamp(0, 5);
            var l = (Rand.Between(-Radius, Radius) * Force / 50).Clamp(0, 2f);
            var d = impulse.Rotate(MathKit.HalfPi, Vector2.Zero);
            d.Normalize();

            Velocity *= 2;
            Alpha = 0;
            Size = 0;
            Color = BaseColor;
            Width = 1;
            Height = (Force / 20).Clamp(.1f, 2);
            Position = origin + l * d;
            Scale = Vector2.Zero;

            var fadeOutTime = (size * .01f * Force).Clamp(0.1f, 1f);

            t.RunInParallel(
                new Tween(v => Scale = new Vector2(v, v), 0, size, .1f, Sine.EaseOut),
                new Tween(v => Alpha = v, 0, 1, .1f, Sine.EaseOut))
                .RunInParallel(
                    new Tween(v => Alpha = v, 1, 0, fadeOutTime, Sine.EaseOut),
                    new Tween(v => Scale = new Vector2(v, v), size, 0, fadeOutTime, Sine.EaseOut))
                .Then(Dispose);
        }