当前位置: 代码迷 >> Silverlight >> Silverlight 卡通效果2
  详细解决方案

Silverlight 卡通效果2

热度:5260   发布时间:2013-02-26 00:00:00.0
Silverlight 动画效果2

这个动画绕x轴旋转加上位置偏移

参考代码:

        public MainPage()        {            InitializeComponent();            button2.Visibility = Visibility.Collapsed;        }        int n = -512;        private void button1_Click(object sender, RoutedEventArgs e)        {            button2.Projection = new PlaneProjection {                 RotationX=n<0?270:0            };                                        button2.Visibility = Visibility.Visible;            if (n < 0) button2.Margin = new Thickness(512, button2.Margin.Top, 0, 0);            else button2.Margin = new Thickness(0, button2.Margin.Top, 0, 0);            var st = new Storyboard();            st.Completed += (a, b) =>            {                if (n < 0)                    button2.Visibility = Visibility.Collapsed;            };            var a1 = new DoubleAnimation            {                To=n<0?0:-270,                Duration=TimeSpan.FromSeconds(0.75),                AutoReverse=false            };            Storyboard.SetTarget(a1, button2.Projection);            Storyboard.SetTargetProperty(a1,new PropertyPath("RotationX"));            st.Children.Add(a1);            var a2 = new DoubleAnimation            {                To = n,                Duration = TimeSpan.FromSeconds(0.75),                AutoReverse = false            };            Storyboard.SetTarget(a2, button2.Projection);            Storyboard.SetTargetProperty(a2,new PropertyPath("LocalOffsetX"));            st.Children.Add(a2);                       st.Begin();            n *= -1;        }


 

  相关解决方案