문제

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.

도움이 되었습니까?

해결책

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)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top