diff options
Diffstat (limited to 'Classes/NMPanelMenu.m')
| -rwxr-xr-x | Classes/NMPanelMenu.m | 37 |
1 files changed, 37 insertions, 0 deletions
| diff --git a/Classes/NMPanelMenu.m b/Classes/NMPanelMenu.m new file mode 100755 index 0000000..ee24279 --- /dev/null +++ b/Classes/NMPanelMenu.m | |||
| @@ -0,0 +1,37 @@ | |||
| 1 | /* | ||
| 2 | * NMPanelMenu.m | ||
| 3 | * shapes | ||
| 4 | * | ||
| 5 | * Created by Nate Murray on 7/29/10. | ||
| 6 | * Copyright 2010 YetiApps. All rights reserved. | ||
| 7 | * | ||
| 8 | */ | ||
| 9 | |||
| 10 | #import "NMPanelMenu.h" | ||
| 11 | |||
| 12 | @implementation NMPanelMenu | ||
| 13 | |||
| 14 | -(CCMenuItem *) itemForTouch: (UITouch *) touch | ||
| 15 | { | ||
| 16 | CGPoint touchLocation = [touch locationInView: [[touch view] superview]]; | ||
| 17 | touchLocation = [[CCDirector sharedDirector] convertToGL: touchLocation]; | ||
| 18 | |||
| 19 | CCMenuItem* item; | ||
| 20 | CCARRAY_FOREACH(children_, item){ | ||
| 21 | // ignore invisible and disabled items: issue #779, #866 | ||
| 22 | if ( [item visible] && [item isEnabled] ) { | ||
| 23 | |||
| 24 | CGPoint local = [item convertToNodeSpace:touchLocation]; | ||
| 25 | |||
| 26 | CGRect r = [item rect]; | ||
| 27 | r.origin = CGPointZero; | ||
| 28 | |||
| 29 | if( CGRectContainsPoint( r, local ) ) { | ||
| 30 | return item; | ||
| 31 | } | ||
| 32 | } | ||
| 33 | } | ||
| 34 | return nil; | ||
| 35 | } | ||
| 36 | |||
| 37 | @end | ||
