终于看到动画章节了,本篇主要针对物体移动、变形和渐变移动进行练习。
完成小球自由落体慢镜实例,请大家多多拍砖,废话少说快快 *** 练。
XAML Code:
<UserControl x:Class="FallingBall.Page" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" WIDth="400" Height="300"> <!--小球动画轨迹--> <UserControl.Resources> <!--创建Storyborad--> <Storyboard x:name="fallDown" Storyboard.Targetname="ellipseFall"> <!--水平移动轨迹--> <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(Canvas.left)"> <!--下落水平移动--> <SplineDoubleKeyFrame KeyTime="0:0:5" Value="50"/> <!--d起水平移动--> <SplineDoubleKeyFrame KeyTime="0:0:9" Value="100"/> </DoubleAnimationUsingKeyFrames> <!--垂直移动轨迹--> <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(Canvas.top)"> <!--下落垂直移动--> <SplineDoubleKeyFrame KeyTime="0:0:5" Value="250"/> <!--落地变形移动--> <SplineDoubleKeyFrame KeyTime="0:0:6" Value="255"/> <!--反d变形移动--> <SplineDoubleKeyFrame KeyTime="0:0:7" Value="250"/> <!--反d垂直移动--> <SplineDoubleKeyFrame KeyTime="0:0:9" Value="150"/> </DoubleAnimationUsingKeyFrames> <!--小球垂直变形--> <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Height"> <!--下落无变形--> <SplineDoubleKeyFrame KeyTime="0:0:5" Value="50"/> <!--压缩垂直变形--> <SplineDoubleKeyFrame KeyTime="0:0:6" Value="45"/> <!--反d垂直变形--> <SplineDoubleKeyFrame KeyTime="0:0:7" Value="50"/> </DoubleAnimationUsingKeyFrames> <!--小球水平变形--> <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="WIDth"> <!--下落无变形--> <SplineDoubleKeyFrame KeyTime="0:0:5" Value="50"/> <!--压缩水平变形--> <SplineDoubleKeyFrame KeyTime="0:0:6" Value="55"/> <!--反d水平变形--> <SplineDoubleKeyFrame KeyTime="0:0:7" Value="50"/> </DoubleAnimationUsingKeyFrames> <!--光点移动轨迹--> <PointAnimationUsingKeyFrames Storyboard.Targetname="ellipseBrush" Storyboard.TargetProperty="GradIEntOrigin"> <!--落地光点移动--> <linearPointKeyFrame KeyTime="0:0:5" Value="0.6,0.1"></linearPointKeyFrame> <!--反d光点移动--> <linearPointKeyFrame KeyTime="0:0:9" Value="0.3,0.1"></linearPointKeyFrame> </PointAnimationUsingKeyFrames> </Storyboard> </UserControl.Resources> <GrID x:name="LayoutRoot" Background="White"> <Canvas> <!--创建小球--> <Ellipse x:name="ellipseFall" WIDth="50" Height="50"> <Ellipse.Fill> <!--创建渐变产生光点效果--> <RadialGradIEntBrush x:name="ellipseBrush" RadiusX="1" RadiusY="1" GradIEntOrigin="1,0.5"> <GradIEntStop color="White" Offset="0"></GradIEntStop> <GradIEntStop color="Blue" Offset="1"></GradIEntStop> </RadialGradIEntBrush> </Ellipse.Fill> </Ellipse> <!--创建地平线--> <Path stroke="Black" Data="M0,300 L400,300 Z"/> </Canvas> </GrID> </UserControl>
C# Code:
namespace FallingBall { public partial class Page : UserControl { public Page() { InitializeComponent(); //开始动画 fallDown.Begin(); } } }
效果图:
参考自《Pro Silverlight2 in C# 2008》CHAPTER 9 ■ ANIMATION 下次要搞一个汽车人变形动画~~
总结以上是内存溢出为你收集整理的Silverlight2 边学边练 之三 小球自由落体全部内容,希望文章能够帮你解决Silverlight2 边学边练 之三 小球自由落体所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)