Frage

Looking for some direction on this. Say you have a ring of radius r. Inside the ring you have a circle of radius c, where c < r. I want the user to be able to grab the inner circle and move/throw it, but circle should be constrained to stay inside the ring. Any suggestions on the following?

  1. handling the touch events
  2. the math involved to constrain the view to a circle?

I am working in iOS, but the concept is general.

War es hilfreich?

Lösung

Not sure what you mean by "handling touch events", but here's the math:

hypot(circle.center.y - ring.center.y, circle.center.x - ring.center.x) < (r - c)
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top