Welcome to the iMore Forums Create Your Account or Ask a Question Answers in 5 minutes - no registration required!
Results 1 to 2 of 2
  1. Thread AuthorThread Author   #1  
    EnterpriseGlobe's Avatar
    iPhone Intermediate

    124 Posts

    Default iPhone Drawing Issue

    newbie here on IPhone SDK development issue.

    I created a circle with CGContextAddEllipseInRect() and It is working fine.
    I have some other view (ball) which I want to move inside the circle randomly (Random moving I did already).
    What I want is , If Ball view touches the circle line it has to move back.

    How can I know the whether the ball touches the circle line or not ?

    Looking forward for your response guys.
  2. #2  
    Vita Alex's Avatar
    iPhone Newbie

    26 Posts


    Check how close the ball's center is to the circle's center.

    If it's less then their diameters combined - then yes, it touches

    Edit: You meant inside. In this case the solution is different, but same approach. You should be able to figure it out

Posting Permissions