wp8实现关键帧动画
来源:互联网 发布:十大悖论知乎 编辑:程序博客网 时间:2024/06/05 20:00
下面实例实现线性关键针动画
1、建一个圆,定一个平移类TranslateTransform和缩放类ScaleTransform
<Ellipse Fill="Red" HorizontalAlignment="Left" Height="117" Margin="10,25,0,0" VerticalAlignment="Top" Width="117"> <Ellipse.RenderTransform> <TransformGroup> <TranslateTransform x:Name="tt" /> <ScaleTransform x:Name="st"/> </TransformGroup> </Ellipse.RenderTransform> </Ellipse>然后我们定义Storyboard启动线性关键帧动画的
<phone:PhoneApplicationPage.Resources> <Storyboard x:Name="sb"> <DoubleAnimationUsingKeyFrames Storyboard.TargetName="tt" Storyboard.TargetProperty="X"> <LinearDoubleKeyFrame Value="0" KeyTime="0:0:0"/> <LinearDoubleKeyFrame Value="350" KeyTime="0:0:3"/> <!--<LinearDoubleKeyFrame Value="350" KeyTime="0:0:3.6"/>--> <LinearDoubleKeyFrame Value="0" KeyTime="0:0:6.6"/> </DoubleAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames Storyboard.TargetName="st" Storyboard.TargetProperty="CenterX"> <LinearDoubleKeyFrame Value="0" KeyTime="0:0:0"/> <LinearDoubleKeyFrame Value="350" KeyTime="0:0:3"/> <!--<LinearDoubleKeyFrame Value="350" KeyTime="0:0:3.6"/>--> <LinearDoubleKeyFrame Value="0" KeyTime="0:0:6.6"/> </DoubleAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames Storyboard.TargetName="st" Storyboard.TargetProperty="ScaleY"> <LinearDoubleKeyFrame Value="1" KeyTime="0:0:3"/> <LinearDoubleKeyFrame Value="1.2" KeyTime="0:0:3.3"/> <LinearDoubleKeyFrame Value="1" KeyTime="0:0:3.6"/> </DoubleAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames Storyboard.TargetName="st" Storyboard.TargetProperty="ScaleX"> <LinearDoubleKeyFrame Value="1" KeyTime="0:0:3"/> <LinearDoubleKeyFrame Value="0.8" KeyTime="0:0:3.3"/> <LinearDoubleKeyFrame Value="1" KeyTime="0:0:3.6"/> </DoubleAnimationUsingKeyFrames> </Storyboard> </phone:PhoneApplicationPage.Resources>
效果实现小球的压缩反弹
下面实例实现样条关键针动画
1、定义一个圆
<Ellipse Fill="Red" HorizontalAlignment="Left" Height="100" Margin="169,10,0,0" Stroke="Black" VerticalAlignment="Top" Width="109" MouseLeftButtonDown="Ellipse_MouseLeftButtonDown_1"> <Ellipse.RenderTransform> <TranslateTransform x:Name="st" Y="0" /> </Ellipse.RenderTransform> </Ellipse>然后我们定义Storyboard启动样条关键帧动画
<Grid.Resources> <Storyboard x:Name="sb"> <DoubleAnimationUsingKeyFrames Storyboard.TargetName="st" Storyboard.TargetProperty="Y"> <LinearDoubleKeyFrame Value="0" KeyTime="0:0:0"/> <SplineDoubleKeyFrame Value="550" KeyTime="0:0:1" KeySpline="0,0 1,0"/> <SplineDoubleKeyFrame Value="250" KeyTime="0:0:1.8" KeySpline="0,0 0,1"/> <SplineDoubleKeyFrame Value="500" KeyTime="0:0:2.4" KeySpline="0,0 1,0"/> </DoubleAnimationUsingKeyFrames> </Storyboard> </Grid.Resources>
样条关键针动画与线性关键针的区别在于速度的变化,样条关键针动画可以自由控制一个时间段内的速度的变化,类似于重力加速度
下面实例实现离散关键针动画
1、定义一个圆
<Ellipse MouseLeftButtonDown="Ellipse_MouseLeftButtonDown_1" Margin="45,47,59,224"> <Ellipse.Fill> <RadialGradientBrush x:Name="rgb" GradientOrigin="0.5,0.5"> <RadialGradientBrush.GradientStops> <GradientStop Color="White" Offset="0"/> <GradientStop Color="Blue" Offset="1"/> </RadialGradientBrush.GradientStops> </RadialGradientBrush> </Ellipse.Fill> </Ellipse>
然后我们定义Storyboard启动离散动画的
<Grid.Resources> <Storyboard x:Name="sb"> <PointAnimationUsingKeyFrames Storyboard.TargetName="rgb" Storyboard.TargetProperty="GradientOrigin" RepeatBehavior="Forever"> <DiscretePointKeyFrame Value="0.1,0.3" KeyTime="0:0:0"/> <DiscretePointKeyFrame Value="0.2,0.4" KeyTime="0:0:1"/> <DiscretePointKeyFrame Value="0.3,0.5" KeyTime="0:0:2"/> <DiscretePointKeyFrame Value="0.4,0.6" KeyTime="0:0:3"/> <DiscretePointKeyFrame Value="0.5,0.7" KeyTime="0:0:4"/> <DiscretePointKeyFrame Value="0.6,0.8" KeyTime="0:0:5"/> <DiscretePointKeyFrame Value="0.7,0.9" KeyTime="0:0:6"/> </PointAnimationUsingKeyFrames> </Storyboard> </Grid.Resources>
离散关键帧动画相对于前面两种的区别在于它是从一个点直接到另外一个点的不是平滑移动的
0 0
- wp8实现关键帧动画
- wp8基于帧动画
- wp8基于属性实现动画
- 使用关键帧动画实现转圈
- [CAAnimation核心动画练习二]关键帧动画,实现抖动
- 核心动画-关键帧动画
- 核心动画(关键帧动画)
- MD2关键帧动画
- 关键帧动画。
- 关键帧动画
- 关键帧动画CAKeyframeAnimation
- 关键帧动画CAKeyframeAnimation
- 关键帧动画CAKeyframeAnimation
- 关键帧动画
- 关键帧动画CAKeyframeAnimation
- OSG 关键帧动画
- 关键帧和动画
- 关键帧动画CAKeyframeAnimation
- JavaScript 脚本化文档之一(学习笔记)
- javascript中的发布/订阅模式
- Eclipse中添加文档注释快捷键
- 指尖上的电商---(7)Solr索引基本操作
- centos 6.4 修改ssh默认端口22为其他端口详尽安全教程(包含SELinux,iptables设置)
- wp8实现关键帧动画
- maven dependency scope
- js笔记 Date时间格式
- 数据库范式(1NF 2NF 3NF BCNF)
- C# Socket粘包
- 【甘道夫】Mapreduce实现矩阵乘法的算法思路
- MapReduce中文翻译
- ThreadLocal用法学习
- c# using用法-sql驱动操作sqlserver