Hi fellow cocos2d game devs, i've a simple problem
I am implementing a CCScene that has two CCLayers on it, one is the game and the other is the HUD implemented as so:
+ (CCScene *)scene {
CCScene *scene = [CCScene node];
LevelLayer *layer = [LevelLayer node];
LevelHUDLayer *hud = [LevelHUDLayer node];
layer = [layer init];
[layer setHUDLayer:hud];
[hud setParentLevel:layer];
[scene addChild:hud z:HUD_ZLevel];
[scene addChild:layer];
return scene;
}
And that works great. I also have a UIPinchGestureRecognizer that I implement as so:
- (void)onEnterTransitionDidFinish {
pinch = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(makePinch:)];
[[CCDirector sharedDirector].view addGestureRecognizer:pinch];
}
And then I catch the gestures later on in code like so:
self.scale = pinch.scale;
This works flawlessly EXCEPT I want to ensure that only the game layer picks up the gestures and not the HUDLayer as well. Right now touching the HUDLayer's controls and trying to move the character around on the screen causes the level to scale, it's quite annoying.
So my question is how do I assign ONLY the LevelLayer to pick up the Gesture Recognizer? I think this would be easy to do if I could access the CCLayer's UIView but it seems as though I can only access CCDirector.sharedDirector.view
Thanks ahead of time!