你好,
如果你的图形是在Canvas上绘制的,可以使用 VisualTreeHelper.FindElementsInHostCoordinates 方法是查看试图元素是否在指定点构成的集合中:http://msdn.microsoft.com/zh-cn/library/cc838402(v=vs.95).aspx
private bool IsCollision(Point p)
{
var hostPoint = this.canvas.TransformToVisual(this.rootVisual).TransformPoint(p);
return CheckCollisionPoint(hostPoint, this.canvas);
}
private bool CheckCollisionPoint(Point point, UIElement subTree)
{
var hits = VisualTreeHelper.FindElementsInHostCoordinates(point, subTree);
return hits.Any(x => x != subTree);
}
这里还有一个视频是关于WP7中使用XNA实现碰撞检测的:http://msdn.microsoft.com/en-us/evalcenter/gg259399.aspx
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey.