cocos2d 建立屏蔽层,修改优先级,禁止点击的事件向下传递!网上大部的资料都是 CCDirector::sharedDirector()->getTouchDispatcher()->addTargetedDelegate(this,-129,true);this
为层添加一个addTargetedDelegatespa
当不使用这个层时还要在 onExit事件里删除掉。code
光听起来就以为麻烦。其实cocos2dx 里的层都有屏蔽功能 。只要修改一下属性就能够了。以下:事件
this->setTouchEnabled(true); this->setTouchPriority(-129); this->setTouchMode(kCCTouchesOneByOne); this->registerWithTouchDispatcher();
这样这个层就能够禁止向下传事件。固然 没有addTargetedDelegate ,也就不须要再去在onExit事件里删除。get
PS:记得重载ccTouchBegan方法it