I really assistance. Im a little confused.
i have a circle sprite, and this code
-(void)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
CGSize winSize =[[CCDirector sharedDirector] winSize];
UITouch* myTouch = [touches anyObject];
CGPoint location = [myTouch locationInView: [myTouch view]];
location = [[CCDirector sharedDirector]convertToGL:location];
CCSprite *circleSprite = (CCSprite*)[self getChildByTag:30];
CGRect correctColorSprite1 = [circleSprite boundingBox];
if (CGRectContainsPoint(correctColorSprite1, location)) {
NSLog(@"inside");
}
as i know there is a bounding box, when i touch slightly outside of the top circle it will still detect the touch.
i have read in some forums that i need to detect distance of the centre of the sprite and the touch point. But i really don't know how to write that code. My circle size is around 50 points.
I hope someone can help me out give me some snippets of a improved code to detect the touch only in the circle. Not with the bounding box. Your help is very great full.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…