I have created a circle with draw function in cocos2d, I am trying to detect touch point on circle line, lets say user touches bottom of the circle I want to print 270, if user touches top of the circle I want to print 90 etc….
I have looked this questions but they detect a sprite first then just compare if touches inside or outside of the circle
http://www.cocos2d-iphone.org/forum/topic/21629
how to detect touch in a circle
- (void) draw
{
CGSize winSize = [[CCDirector sharedDirector] winSize];
glLineWidth(10.0f);
ccDrawColor4F(0.2f, 0.9f, 0.02f, 0.6f);
CGPoint center = ccp(winSize.width*0.88, winSize.height*0.8);
CGFloat radius = 100.f;
CGFloat angle = 0.f;
NSInteger segments = 100;
BOOL drawLineToCenter = YES;
ccDrawCircle(center, radius, angle, segments, drawLineToCenter);
}
How can I detect a touch point on the circle line?
Try this , didnt test the code , improved it according to your needs