maybe this is a noob question (sorry!)
but im using CGRect to create multiple rectangles. How could i detect if they got within 5 pixels of each other?
maybe this is a noob question (sorry!)
but im using CGRect to create multiple rectangles. How could i detect if they got within 5 pixels of each other?
As beer implied, there's nothing built-in for this, but you can use trigonometry to figure it out. Specifically the Pythagorean theorem - think of your two points as being on the hypotenuse of a triangle. In code: