2010-10-17 37 views
1

我看到这种文字效果吨广告和最近的网站。如何创建一个Silverlight摆摆动3D文本效果

我已经找到了在Flash和JavaScript中实现它的方法,但没有什么能直接帮助我在Silverlight中实现它。

下面的效果的例子: http://activeden.net/item/pendulum-swing-3d-component-as3/85056

基本上想法是文本是广告牌上,如果翻转到视图沿着顶部水平轴。

任何人都知道一个教程或一种方法来实现这种效果。我无法将它重新创建到效果匹配的位置,并且看起来很自然。

+0

可能重复的[在Silverlight摆锤状动画。](http://stackoverflow.com/questions/3859126/pendulum-like-animation-in-silverlight) – ctacke 2010-10-17 15:32:45

回答

3

此动画需要的3D透视外观可以通过动画获得PlaneProjection。 “摆”的过冲然后回摆可以近似使用缓动功能。

这里是一个粗略的尝试,它的接近,但你可能会需要巧妙的人数多一点,以获得更平滑的结果(最终沉淀是不完全正确): -

<Grid x:Name="LayoutRoot" Background="White"> 
    <Grid.Resources> 
     <Storyboard x:Name="Swing"> 
      <DoubleAnimationUsingKeyFrames Duration="0:0:1" Storyboard.TargetName="Notice" 
       Storyboard.TargetProperty="(Border.Projection).(PlaneProjection.RotationX)"> 
       <EasingDoubleKeyFrame KeyTime="0:0:0.75" Value="15"> 
        <EasingDoubleKeyFrame.EasingFunction> 
         <BackEase EasingMode="EaseOut" Amplitude="1.3" /> 
        </EasingDoubleKeyFrame.EasingFunction> 
       </EasingDoubleKeyFrame> 
       <EasingDoubleKeyFrame KeyTime="0:0:1" Value="0"> 
        <EasingDoubleKeyFrame.EasingFunction> 
         <BackEase EasingMode="EaseOut" Amplitude="2" /> 
        </EasingDoubleKeyFrame.EasingFunction> 
       </EasingDoubleKeyFrame> 
      </DoubleAnimationUsingKeyFrames> 
     </Storyboard> 

    </Grid.Resources> 
    <Border x:Name="Notice" Background="Orange" CornerRadius="5" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="10" > 
     <Border.Projection> 
      <PlaneProjection RotationX="90" CenterOfRotationY="0" /> 
     </Border.Projection> 
     <TextBlock FontSize="24" FontWeight="Bold" Foreground="Yellow">NICE EFFECT?</TextBlock> 
    </Border> 
    <Button Content="Go" Height="35" HorizontalAlignment="Left" Margin="214,13,0,0" Name="button1" VerticalAlignment="Top" Width="142" Click="button1_Click" /> 
</Grid> 

代码: -

private void button1_Click(object sender, RoutedEventArgs e) 
    { 
     ((PlaneProjection)Notice.Projection).RotationX = 90; 
     Swing.Begin(); 
    }