如何检查两个对象在Canvas小部件中是否重叠?
假设我在画布上有一些物体,它们的标签是 'stopped'
和 'flying'
。
我该怎么检查这些物体是否有重叠的地方呢?
1 个回答
2
你可以使用一个叫做 find_overlapping
的方法。
find_overlapping(x1, y1, x2, y2) => tuple
Returns a tuple of all items that overlap the given rectangle, or that are completely enclosed by it.
然后,你可以遍历结果列表,寻找你需要的标签。