I have an object that can be moved across the screen with the finger. This object is an image, a small image, like a thumbnail.
On the screen I have a background image where 10 rectangles were drawn. This rectangles are part of the background image. The background image is dumb, just a UIImageView.
I have 10 sounds I want to play every time the thumbnail passes over one of the 10 areas, represented by the 10 rectangles on the background. Each area has its own sound.
All I have is the size of the translating thumbnail and its coordinates (like origin, center, width and height). I have the origin (x and y) coordinates in realtime.
The point is: how to detect if the translating thumbnail is over one of the 10 squares considering a certain tolerance (example +- 10 pixels) and discover what area is it?
The problem: as I have the origin coordinates in realtime I can always create a loop to check if this value is inside one of the 10 rectangles, but this is CPU intensive because the loop will run for each pixel the thumbnail scrolls.
Any other ideas on how to do that?
thanks for any help.