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