cocos2d-x,点击出现弹出窗口,如何将下面层的点击事件禁掉?需要设置listener:setSwallowTouches(true),这样就不会触发下一层的事件,还有在onTouchBegan中返回true
如
local layerColor=Layer2.new() local function onTouchBegan(touch,event) return true end local listener=cc.EventListenerTouchOneByOne:create() listener:setSwallowTouches(true) listener:registerScriptHandler(onTouchBegan,cc.Handler.EVENT_TOUCH_BEGAN) local eventDispatcher = layerColor:getEventDispatcher() eventDispatcher:addEventListenerWithSceneGraPHPriority(listener,layerColor)