Ejemplo n.º 1
0
        private IEnumerator MoveOnCurve(Vector2 from, Vector2 anchor, Vector2 to) {
            SimpleCurve curve = new SimpleCurve(from, to, anchor);
            var duration = curve.GetLengthParametric(32) / 500f;
            Vector2 was = from;
            for (var t = 0.016f; t <= 1f; t += Engine.DeltaTime / duration) {
                Position = curve.GetPoint(t).Floor();
                sprite.Rotation = Calc.Angle(curve.GetPoint(Math.Max(0f, t - 0.05f)),
                    curve.GetPoint(Math.Min(1f, t + 0.05f)));
                // sprite.Scale.X = 1.25f;
                sprite.Scale.X = -1.25f;
                sprite.Scale.Y = 0.7f;
                if ((was - Position).Length() > 32f) {
                    TrailManager.Add(this, trailColor, 1f, false);
                    was = Position;
                }

                yield return null;
            }

            Position = to;
        }