1

In my processing program, I have made several circles positioned randomly. I used the distance formula to calculate if the mouse is over a certain area.

However, this algorithm fails when circles overlap because it thinks the mouse is over both circles. What is a way to only detect if the mouse is on the circle on top?

dangerChihuahua007
  • 20,299
  • 35
  • 117
  • 206

1 Answers1

1

Not sure how you are implementing it, but one option would be to give each of your circles an index. Start at 0 and increment for each circle. Then, when your algorithm checks the circles, only use the circle with the highest index value.

DJ Quimby
  • 3,669
  • 25
  • 35