以编程方式将动画插入StoryBoard [英] Insert animations to a StoryBoard programmatically

查看:70
本文介绍了以编程方式将动画插入StoryBoard的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码有问题.下面的代码效果很好..使用这些代码,我一次不能动画多个对象.所以我想,我必须将它们添加到情节提要中,这样我才能一次对多个对象进行动画处理.我怎样才能做到这一点?对不起,我的英语不好..

I have a problem with my code. The codes bellow are work well.. I can''t animate more than 1 object in a time with these code. So i thought, i must add them to a storyboard, so i can animate more than 1 object in a time. how can i do that? sorry for my bad english..

Private Sub animation(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs)
       If anime_counter < counter Then
           Dim daX As New DoubleAnimation
           Dim daY As New DoubleAnimation

           If anime_counter = 0 Then
               daX.From = Pict1.Margin.Left
               daY.From = Pict1.Margin.Top
           Else
               daX.From = path(anime_counter - 1).X - Pict1.Margin.Left
               daY.From = path(anime_counter - 1).Y - Pict1.Margin.Top
           End If
           daX.To = path(anime_counter).X - Pict1.Margin.Left
           daY.To = path(anime_counter).Y - Pict1.Margin.Top

           Dim pixelsPerSecond As Double = 200
           Dim distance As Double = Math.Sqrt((daX.To - daX.From) * (daX.To - daX.From) + (daY.To - daY.From) * (daY.To - daY.From))
           daX.Duration = TimeSpan.FromSeconds(distance / pixelsPerSecond)
           daY.Duration = TimeSpan.FromSeconds(distance / pixelsPerSecond)
           AddHandler daX.Completed, AddressOf animation

           Dim tt As New TranslateTransform
           Pict1.RenderTransform = tt
           tt.BeginAnimation(TranslateTransform.XProperty, daX)
           tt.BeginAnimation(TranslateTransform.YProperty, daY)

           anime_counter += 1
       Else
           anime_counter = 0
       End If
   End Sub

推荐答案

只需为每个动画创建一个情节提要.
Just create one storyboard for each animation.


我该怎么做?我不能以编程方式添加故事板..::(
how can i do that?? i can''t add the story board programmatically.. :(


帮助我..真的需要帮助... T__T
help me pls.. really need help... T__T


这篇关于以编程方式将动画插入StoryBoard的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆