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
这篇博客介绍了如何在cocos2dx 2.x版本中,通过递归方法设置节点的触摸穿透功能,包括`setTouchSwallowEnabled`方法的使用及对子节点的遍历处理。

1967

被折叠的 条评论
为什么被折叠?



