Sure, I had to figure that out for my game Star Catch. There may be better ways of doing it but this is how I did it. I actually found the algorithm online (sorry I can't remember the source) I did a search for detecting a point inside a polygon.
I created a NSMutableArray to hold my point. I add the points in my touchevents.
- (BOOL) testNodeInLoop:(CCNode *)node { CGPoint prev; // This is more accurate point for the node CGPoint absPoint = [node convertToWorldSpace:CGPointZero]; float x = absPoint.x; float y = absPoint.y; BOOL isIn = NO; CGPoint cp; for(int i = 0, j = [points count] - 1; i < [points count]; j = i++) { [[points objectAtIndex:i] getValue:&cp]; [[points objectAtIndex:j] getValue:&prev]; if( ((cp.y > y) != (prev.y > y)) && (x < (prev.x -cp.x) * (y - cp.y) / (prev.y - cp.y) + cp.x)) { isIn = !isIn; } } return isIn; }
Let me know if this is helpful.