在重力环境下以 canvas 的加速度下落物体?

Falling object with acceleration in canvas like in gravity environment?

我有一个 canvas,里面有边框

<Canvas x:Name="mainCanvas" ManipulationMode="None" Margin="0,12,0,0" MinHeight="400">
     <Border x:Name="manipulateMe" Background="LightGray" Height="200" Width="200"  ManipulationMode="All"/>
</Canvas>

我已经在上面实现了操作功能。然后我需要它总是像空气中的东西一样掉下来。有什么简单的方法吗?

此外,我还想在它接触地面时处理动画:弹跳、滚动……基于它的形状。我需要游戏引擎、框架或类似的东西吗?

Then I need it always falling down like things on air.

如果您只想要跌落效果,您可以使用 TranslateTransform 沿 Y 坐标为元素设置动画。例如:

<StackPanel Margin="15">
   <StackPanel.Resources>
       <Storyboard x:Name="myStoryboard">
           <DoubleAnimation
               RepeatBehavior="Forever"
               Storyboard.TargetName="myTranslateTransform"
               Storyboard.TargetProperty="Y"
               From="0"
               To="360"
               Duration="0:0:5" />
       </Storyboard>
   </StackPanel.Resources>
   <Rectangle
       Width="50"
       Height="50"
       Fill="RoyalBlue"
       PointerPressed="StartAnimation">
       <Rectangle.RenderTransform>
           <TranslateTransform x:Name="myTranslateTransform"  />    
       </Rectangle.RenderTransform>
   </Rectangle>
</StackPanel>

private void StartAnimation(object sender, PointerRoutedEventArgs e)
{
    myStoryboard.Begin();
}

更多关于转换的细节请参考this article

Beside, I also want handle the animation when it touch the ground : bounce, rolling ... base on its shape.

对于反弹效果,您可以使用 BounceEase, one of the Easing functions. For rolling you could use RotateTransform combine with TranslateTransform. For how to combine two animations please reference this article

总而言之,您可以在 UWP 动画库中找到许多您想要的动画。请参考Animations overview. If this cannot meet your requirements, you may consider to use Composition animations. For samples you can reference WindowsUIDevLabs.

Physics XAML Helper是我需要的