使用暂停时,旋转动画会在点击时抖动

时间:2013-12-02 05:49:20

标签: c# xaml animation windows-phone-8

我有一个旋转的图像,当你点击它时,它停止并收集它上面的旋转。但由于某种原因,有时候它会从它被敲击的位置向后(或周围)猛拉。有谁知道如何解决这个问题:

XAML:

<StackPanel>
<StackPanel.Resources>
<Storyboard x:Name="AttackCircleAnimation">
<DoubleAnimation x:Name="combatCircleRotation"
  Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.Rotation)"
  Storyboard.TargetName="combatCircleSword" Duration="0:0:1" From="0" To="360"   RepeatBehavior="Forever" />
</Storyboard>
</StackPanel.Resources>
</StackPanel>

<Image x:Name="combatCircleSword" RenderTransformOrigin="0.5,0.5" Tap="TapProcessAttack">
<Image.RenderTransform>
<CompositeTransform Rotation="0"/>
</Image.RenderTransform>
</Image>

CODE:

private void TapProcessAttack(object sender, System.Windows.Input.GestureEventArgs e)
{
  AttackCircleAnimation.Pause();
  CompositeTransform t = combatCircleSword.RenderTransform as CompositeTransform;
  spinFinalValue = t.Rotation;
}

0 个答案:

没有答案