我正在制作Silverlight程序,用户可以将蠕虫添加到地面。蠕虫必须可以修改。它们可以有三个或更多控制点,用户可以从中移动和编辑蠕虫。蠕虫必须具有最大和最小长度。它还有一些看起来像蠕虫的装备。我用规范样条制作了相当好的蠕虫,但问题是最大和最小长度和装备。我不是在等待任何准备好的代码,而是等待一些新的想法如何实现。
MSPaint :) http://tinypic.com/r/bgxp3m/7
制作的示例答案 0 :(得分:1)
您可以使用Expression Blend中的钢笔工具创建带有贝塞尔曲线的开放路径。然后直接选择工具可以修改点以提供所需的形状。如果在故事板中执行此操作,Expression Blend会将Path数据扩展为未压缩格式,可以对其进行动画制作,命名和引用。这是一个示例蠕虫:
<Grid x:Name="LayoutRoot" Background="White">
<Grid.Resources>
<Storyboard x:Name="wriggle">
<PointAnimation Duration="0:0:0.7" To="59.4217224121094,11.1413049697876" Storyboard.TargetProperty="(Path.Data).(PathGeometry.Figures)[0].(PathFigure.Segments)[1].(BezierSegment.Point1)" Storyboard.TargetName="wormBody" d:IsOptimized="True"/>
<PointAnimation Duration="0:0:0.7" To="21.5,45.9078826904297" Storyboard.TargetProperty="(Path.Data).(PathGeometry.Figures)[0].(PathFigure.Segments)[0].(BezierSegment.Point2)" Storyboard.TargetName="wormBody" d:IsOptimized="True"/>
<PointAnimation Duration="0:0:0.7" To="9.25,28.6580047607422" Storyboard.TargetProperty="(Path.Data).(PathGeometry.Figures)[0].(PathFigure.Segments)[0].(BezierSegment.Point1)" Storyboard.TargetName="wormBody" d:IsOptimized="True"/>
</Storyboard>
</Grid.Resources>
<Path x:Name="wormBody" HorizontalAlignment="Left" Height="67.316" Margin="167,150.092,0,0" Stroke="Black" StrokeThickness="10" UseLayoutRounding="False" VerticalAlignment="Top" Width="91">
<Path.Data>
<PathGeometry FillRule="EvenOdd">
<PathFigure IsFilled="True" IsClosed="False" StartPoint="5,62.3157653808594">
<BezierSegment Point3="42.2093734741211,24.9581699371338" Point2="4.49375009536743,30.3548755645752" Point1="35.375,53.3601760864258"/>
<BezierSegment Point3="86,5" Point2="73.8499984741211,24.9581699371338" Point1="54.1062507629395,22.6553039550781"/>
</PathFigure>
</PathGeometry>
</Path.Data>
</Path>
<Ellipse HorizontalAlignment="Left" Height="15" Margin="246,146,0,0" Stroke="Black" StrokeThickness="10" VerticalAlignment="Top" Width="15"/>
</Grid>