Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

macfanboy

macrumors 6502a
Original poster
Jun 5, 2007
915
162
I was trying to detect when two imageviews (equally sized circles) overlap, and i was going to call a method every 0.01 seconds and using the below code. I thought there may be a better way to do this but i couldnt find out how. Any advice is greatly appreciated!
Code:
if (image1.center.x - image2.center.x = 75) {
     if (image1.center.y - image2.center.y = 75) {
          //Whatever I want
     }
}
 

jpyc7

macrumors 6502
Mar 8, 2009
276
0
Denver, CO
two comments

1. Instead of checking every X seconds, you should just check whenever a circle moves. Or maybe you meant the circle movement rate was X seconds. Anyway, you get the idea that you don't need to check for overlap any faster than the circle movement rate.

2. Your logic works, but you need a 'less than' sign in front of the 75 (which I assume is the radius of the circle).
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.