Question

I have UIView over my CCScene in my cocos2d with box2d game. I have this problem, UIView swallows all the touches and CCLayer's ccTouchesBegin etc. methods don't get called.

Is there any way how can I pass the touches to my CCLayer? I googled this, but I got nothing on this matter, only got results concerning blocking touches from layer to layer.

Does anybody know? All help will be greatly appreciated, thanks in advance

Was it helpful?

Solution 2

Thanks for tips, I tried your code @doctorBroctor, but it didn't work. But I finally made it work through delegation. Just coded delegation methods from UIView to my layer.

OTHER TIPS

In your layer's init function, try adding this code:

[[[CCDirector sharedDirector] touchDispatcher] addTargetedDelegate:self priority:0 swallowsTouches:NO];

If that doesn't work, here are two links that might help you out. The first is a StackOverflow question that seems somewhat similar to yours. The other is a Cocos2D forum question of someone that has the opposite problem as you, but looking at their code and the answers to their question may give you some more things to try.

Good luck, mate!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top