Exemple #1
0
        public static async Task AnimateAsync(this ICollider rectangular, RectangularAnimationOptions options)
        {
            var startX = rectangular.Left();
            var startY = rectangular.Top();
            var startW = rectangular.Bounds.Width;
            var startH = rectangular.Bounds.Height;

            await Animator.AnimateAsync(new FloatAnimatorOptions()
            {
                Duration         = options.Duration,
                AutoReverse      = options.AutoReverse,
                AutoReverseDelay = options.AutoReverseDelay,
                DelayProvider    = options.DelayProvider,
                Loop             = options.Loop,
                EasingFunction   = options.EasingFunction,
                From             = 0,
                To          = 1,
                IsCancelled = options.IsCancelled,
                IsPaused    = options.IsPaused,
                OnSet       = options.OnSet,
                Setter      = v =>
                {
                    var dest   = options.Destination();
                    var xDelta = dest.Left - startX;
                    var yDelta = dest.Top - startY;
                    var wDelta = dest.Width - startW;
                    var hDelta = dest.Height - startH;

                    var frameX      = startX + (v *xDelta);
                    var frameY      = startY + (v *yDelta);
                    var frameW      = startW + (v *wDelta);
                    var frameH      = startH + (v *hDelta);
                    var frameBounds = new RectF(frameX, frameY, frameW, frameH);
                    options.Setter(rectangular, frameBounds);
                }
            });
        }