-
-
Save njt1982/8608940 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Feel free to use. MIT License | |
#import "cocos2d.h" | |
// Layer that will just capture any touch events on it | |
@interface OpaqueLayer : CCLayerColor | |
@end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// OpaqueLayer.m | |
#import "OpaqueLayer.h" | |
@implementation OpaqueLayer | |
- (id) initWithColor:(ccColor4B)color width:(GLfloat)w height:(GLfloat) h { | |
if( (self=[super initWithColor:color width:w height:h]) ) { | |
[self setTouchPriority:kCCMenuHandlerPriority]; | |
[self setTouchMode:kCCTouchesOneByOne]; | |
[self setTouchEnabled:YES]; | |
} | |
return self; | |
} | |
-(void) registerWithTouchDispatcher { | |
[[[CCDirector sharedDirector] touchDispatcher] addTargetedDelegate:self | |
priority:_touchPriority | |
swallowsTouches:_touchSwallow]; | |
} | |
// just swallow any touches meant for us | |
-(BOOL) ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event { | |
CGPoint point = [self convertTouchToNodeSpace:touch]; | |
CGRect rect = CGRectMake(0, 0, self.contentSize.width, self.contentSize.height); | |
return CGRectContainsPoint(rect, point); | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment