Example #1
0
            private void CreateAnimation()
            {
                if (animation == null)
                {
                    var anim1 = ObjectAnimator.OfFloat(balls[0], "y", 0f, Height - balls[0].Height);
                    anim1.SetDuration(500);
                    var anim2 = anim1.Clone();
                    anim2.SetTarget(balls[1]);
                    anim1.Update += delegate { Invalidate(); };

                    var ball2    = balls[2];
                    var animDown = ObjectAnimator.OfFloat(ball2, "y", 0f, Height - ball2.Height);
                    animDown.SetDuration(500);
                    animDown.SetInterpolator(new AccelerateInterpolator());
                    var animUp = ObjectAnimator.OfFloat(ball2, "y", Height - ball2.Height, 0f);
                    animUp.SetDuration(500);
                    animUp.SetInterpolator(new DecelerateInterpolator());

                    var s1 = new AnimatorSet();
                    s1.PlaySequentially(animDown, animUp);
                    animDown.Update += delegate { Invalidate(); };
                    animUp.Update   += delegate { Invalidate(); };
                    var s2 = (AnimatorSet)s1.Clone();
                    s2.SetTarget(balls[3]);

                    animation = new AnimatorSet();
                    animation.PlayTogether(anim1, anim2, s1);
                    animation.PlaySequentially(s1, s2);
                }
            }
            private void CreateAnimation()
            {
                if (animation == null)
                {
                    var anim1 = ObjectAnimator.OfFloat(balls[0], "y", 0f, Height - balls[0].Height);
                    anim1.SetDuration(500);
                    var anim2 = anim1.Clone();
                    anim2.SetTarget(balls[1]);
                    anim1.Update += delegate { Invalidate(); };

                    var ball2 = balls[2];
                    var animDown = ObjectAnimator.OfFloat(ball2, "y", 0f, Height - ball2.Height);
                    animDown.SetDuration(500);
                    animDown.SetInterpolator(new AccelerateInterpolator());
                    var animUp = ObjectAnimator.OfFloat(ball2, "y", Height - ball2.Height, 0f);
                    animUp.SetDuration(500);
                    animUp.SetInterpolator(new DecelerateInterpolator());

                    var s1 = new AnimatorSet();
                    s1.PlaySequentially(animDown, animUp);
                    animDown.Update += delegate { Invalidate(); };
                    animUp.Update += delegate { Invalidate(); };
                    var s2 = (AnimatorSet)s1.Clone();
                    s2.SetTarget(balls[3]);

                    animation = new AnimatorSet();
                    animation.PlayTogether(anim1, anim2, s1);
                    animation.PlaySequentially(s1, s2);
                }
            }