質問

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