views:

32

answers:

1

Hello,

I am developing a game on Iphone using cocos2d. I have a CClayer containing 20 CCSprite. I am playing a sound and I would like to disable the touch events on all the CCSprite or on the entire layer while the sound is playing. I looked at the property of CCLayer called isTouchEnabled but the behavior doesn't propagate to the children (all the CCSprite). Unless it is not documented, there seems to be no equivalent property for CCsprite. Does anybody know an easy way to this? Thanks

A: 

A member of another forum posted this solution

So all your sprites normally receive touch events? If you know when the sound is playing, you just could have them check that and ignore the touch if the sound is playing. For example, if your sprites implement the CCTargetedTouchDelegate protocol, you could do something like:

  • (BOOL)ccTouchBegan:(UITouch*)touch withEvent:(UIEvent*)event { if (soundIsPlaying) { return NO; // i.e., the sprite is currently uninterested in the touch } // Other checks and behaviour here. return YES; }
Cyril