cocos2dx - 2.x版本---递归设置触摸穿透

来源:互联网 发布:练颜体用什么毛笔知乎 编辑:程序博客网 时间:2024/06/16 15:15

cocos2dx - 2.x版本---递归设置触摸穿透


--[[

递归设置触摸穿透

]]

function BaseUtil:setCascadeTouchSwallowEnabled(target,enabled)

    if not target then

        return

    end

    target:setTouchSwallowEnabled(enabled)

    local childrencount = target:getChildrenCount()

    if childrencount>0 then

        local children = target:getChildren()

        for i=0,childrencount-1 do

            local child = children:objectAtIndex(i)

            child:setTouchSwallowEnabled(enabled)

            --递归调用

            BaseUtil:setCascadeTouchSwallowEnabled(child,enabled)

        end

    end

end


0 0
原创粉丝点击