0

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)

Raptor
  • 53,206
  • 45
  • 230
  • 366

2 Answers2

2

Here are some references you might try:

Community
  • 1
  • 1
Sixten Otto
  • 14,816
  • 3
  • 48
  • 60
  • thanks for finding me references! that helps! i hope iPhone SDK will release functions for circle-rectangle collision detection. – Raptor Oct 21 '09 at 04:13
1

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

  • Thanks for replying my old question. Your solution assumes the use of cocos2d engine, but at the time I ask this question, I didn't use the engine. Now, cocos2d works for me pretty well. – Raptor Nov 28 '11 at 01:54
  • This site looks defunct :( – Ian May 15 '15 at 00:56