Raptor
Raptor

Reputation: 54212

Collision Detection in iPhone SDK: Inaccurate CGRectIntersectsRect

When there are two objects going to collide, I check them with CGRectIntersectsRect. However, before it returns me with YES (they collide), they are already overlapped. Is there any other way to detect and resolve collision?

My workaround is to compare their Y axis and move the object far apart from each other, once they are detected collision.

Also, one of my objects is a circle, is there any other functions for iPhone SDK to detect the collision better? (currently I treat the circle as a rectangle, as its frame is a rectangle)

Upvotes: 0

Views: 2339

Answers (2)

Bob Uelenad
Bob Uelenad

Reputation: 31

You can use CGPath to detect collission for irregular rigid bodies. See http://bobueland.com/cocos2d/?p=379

Upvotes: 1

Sixten Otto
Sixten Otto

Reputation: 14816

Here are some references you might try:

Upvotes: 2

Related Questions