WPF动画 实现转折点运动

            #region 实现复杂的移动 --- 移动过程中出现转折点
            DoubleAnimationUsingKeyFrames DakX = new DoubleAnimationUsingKeyFrames();
            DoubleAnimationUsingKeyFrames DakY = new DoubleAnimationUsingKeyFrames();

            //设置动画时长
            DakY.Duration = new Duration(TimeSpan.FromMilliseconds(900));
            DakX.Duration = new Duration(TimeSpan.FromMilliseconds(900));
            //创建、添加关键帧
            LinearDoubleKeyFrame y1 = new LinearDoubleKeyFrame();
            LinearDoubleKeyFrame y2 = new LinearDoubleKeyFrame();
            LinearDoubleKeyFrame y3 = new LinearDoubleKeyFrame();

            y1.KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(300));
            y1.Value = 0;
            y2.KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(600));
            y2.Value = 180;
            y3.KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(900));
            y3.Value = 180;

            LinearDoubleKeyFrame x1 = new LinearDoubleKeyFrame();

            LinearDoubleKeyFrame x2 = new LinearDoubleKeyFrame();
            LinearDoubleKeyFrame x3 = new LinearDoubleKeyFrame();

            x1.KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(300));
            x1.Value = 200;
            x2.KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(600));
            x2.Value = 0;
            x3.KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(900));
            x3.Value = 200;

            DakY.KeyFrames.Add(y1);
            DakY.KeyFrames.Add(y2);
            DakY.KeyFrames.Add(y3);
            DakX.KeyFrames.Add(x1);
            DakX.KeyFrames.Add(x2);
            DakX.KeyFrames.Add(x3);

            //执行动画
            this.tt.BeginAnimation(TranslateTransform.XProperty, DakX);
            this.tt.BeginAnimation(TranslateTransform.YProperty, DakY);
            #endregion

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值