开发者

Cocoa Touch - How to check if a non-rectangular object in a UIImageView intersects another object?

Say I have a UIImageView that contains an 开发者_StackOverflow中文版image of an object that is not rectangular, i.e. a round ball. How can I check if another UIImageView (rectangular or not) intersects, or contains a point in, that object (not its frame)?

Basic example:

I have two balls rolling around on the screen, and I want to check for collision. But I don't want to check if their rects intersects eachother, since the balls are not rectangular.


I think if you have limited set of possible shapes then it is better to perform the check for each possible pair of object shapes rather then some generic algorithm. For example two circles intersect if the distance between their centers is less then the sum of their radiuses etc.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜