daixinet

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

iPad塔防的防守兵的效果很炫,2个小时用WPF模拟了一个。

效果图:

关键代码:

    <Grid>
        <Grid.Background>
            <ImageBrush ImageSource="Koala.jpg"/>
        </Grid.Background>

        <Button Content="Button1" HorizontalAlignment="Left" Margin="187,107,0,0" VerticalAlignment="Top" Width="75" Click="Button_Click_1"/>

        <Grid x:Name="m_Grid" HorizontalAlignment="Left" VerticalAlignment="Top" Height="300" Width="300" MouseUp="m_Grid_MouseUp" Margin="69,31,0,0">
            <Ellipse Stroke="White" StrokeThickness="1">
                <Ellipse.Fill>
                    <RadialGradientBrush Opacity="1" RadiusX="0.5" RadiusY="0.5" GradientOrigin="0.5,0.5">
                        <GradientStop Color="White" Offset="1.1" ></GradientStop>
                        <GradientStop Color="Transparent" Offset="0.92"></GradientStop>
                    </RadialGradientBrush>
                </Ellipse.Fill>
            </Ellipse>
            <Ellipse x:Name="m_Ellipse" Stroke="White" Margin="4">
                <Ellipse.Fill>
                    <RadialGradientBrush Opacity="1" RadiusX="0.5" RadiusY="0.5" GradientOrigin="0.5,0.5">
                        <GradientStop Color="White" Offset="0.97" ></GradientStop>
                        <GradientStop Color="Transparent" Offset="0.96"></GradientStop>
                    </RadialGradientBrush>
                </Ellipse.Fill>
                <Ellipse.Clip>
                    <RectangleGeometry Rect="0,0,100,100" />
                </Ellipse.Clip>
                <Ellipse.RenderTransform>
                    <RotateTransform Angle="0" CenterX="146" CenterY="146"  /> 
                </Ellipse.RenderTransform>
                <Ellipse.Triggers>
                    <EventTrigger RoutedEvent="Window.Loaded">
                        <BeginStoryboard>
                            <Storyboard RepeatBehavior="Forever">
                                <DoubleAnimation Storyboard.TargetName="m_Ellipse"
                                                 Storyboard.TargetProperty="(Ellipse.RenderTransform).(RotateTransform.Angle)"
                                                 To="180" 
                                                 Duration="0:0:5"/>
                            </Storyboard>
                        </BeginStoryboard>
                    </EventTrigger>
                </Ellipse.Triggers>
            </Ellipse>
            <Ellipse x:Name="m_Ellipse2" Stroke="White" Margin="4">
                <Ellipse.Fill>
                    <RadialGradientBrush Opacity="1" RadiusX="0.5" RadiusY="0.5" GradientOrigin="0.5,0.5">
                        <GradientStop Color="White" Offset="0.97" ></GradientStop>
                        <GradientStop Color="Transparent" Offset="0.96"></GradientStop>
                    </RadialGradientBrush>
                </Ellipse.Fill>
                <Ellipse.Clip>
                    <RectangleGeometry Rect="0,0,100,100" />
                </Ellipse.Clip>
                <Ellipse.RenderTransform>
                    <RotateTransform Angle="180" CenterX="146" CenterY="146"  />
                </Ellipse.RenderTransform>
                <Ellipse.Triggers>
                    <EventTrigger RoutedEvent="Window.Loaded">
                        <BeginStoryboard>
                            <Storyboard RepeatBehavior="Forever">
                                <DoubleAnimation Storyboard.TargetName="m_Ellipse2"
                                                 Storyboard.TargetProperty="(Ellipse.RenderTransform).(RotateTransform.Angle)"
                                                 To="360" 
                                                 Duration="0:0:5"/>
                            </Storyboard>
                        </BeginStoryboard>
                    </EventTrigger>
                </Ellipse.Triggers>
            </Ellipse>

            <Button Content="PopButton" HorizontalAlignment="Left" Margin="18,126,0,0" VerticalAlignment="Top" Width="75"/>
        </Grid>
        
    </Grid>

 

 

 

posted on 2013-03-26 01:18  daixinet.com  阅读(1263)  评论(0编辑  收藏  举报