Skip to content

Instantly share code, notes, and snippets.

@sdabet
Created January 23, 2013 17:54
Show Gist options
  • Save sdabet/4611017 to your computer and use it in GitHub Desktop.
Save sdabet/4611017 to your computer and use it in GitHub Desktop.
-(CCMenuItem *) itemForTouch: (UITouch *) touch
{
CGPoint touchLocation = [touch locationInView: [touch view]];
touchLocation = [[CCDirector sharedDirector] convertToGL: touchLocation];
CCMenuItem* item;
CCARRAY_FOREACH(children_, item){
// ignore invisible and disabled items: issue #779, #866
if ( [item visible] && [item isEnabled] ) {
CGPoint local = [item convertToNodeSpace:touchLocation];
CGRect r = [item rect];
r.origin = CGPointZero;
if( CGRectContainsPoint( r, local ) )
return item;
}
}
return nil;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment