Skip to content

Instantly share code, notes, and snippets.

@tudormunteanu
Created August 7, 2013 14:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tudormunteanu/6174624 to your computer and use it in GitHub Desktop.
Save tudormunteanu/6174624 to your computer and use it in GitHub Desktop.
Subclass of CCMenu with a custom touch priority. Working for cocos2d 2.0, 2013-08-07.
#import "cocos2d.h"
#import <Foundation/Foundation.h>
@interface MWCCMenu : CCMenu {
}
@property (nonatomic) NSInteger touchPriority;
@end
@implementation MWCCMenu
- (id) initWithArray:(NSArray *)arrayOfItems {
self = [super initWithArray:arrayOfItems];
if (self) {
self.touchPriority = kCCMenuHandlerPriority-2;
}
return self;
}
- (id) initWithItems:(CCMenuItem *)item vaList:(va_list)args {
self = [super initWithItems:item vaList:args];
if (self) {
self.touchPriority = kCCMenuHandlerPriority-2;
}
return self;
}
-(void) registerWithTouchDispatcher
{
CCDirector *director = [CCDirector sharedDirector];
[[director touchDispatcher] addTargetedDelegate:self priority:self.touchPriority swallowsTouches:YES];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment