您的位置:首页 > 移动开发 > Cocos引擎

cocos 获取所有子节点 -lua

2016-07-11 13:28 369 查看
function UiTools:getAllChild(parent)

local node_list = {}

local children = parent:getChildren()

local function seach_child(parente)
local childCount = parente:getChildrenCount()
if childCount < 1 then
node_list[parente:getName()] = parente
else
for i = 1, childCount do
dump(parente)
node_list[parente:getName()] = parente
seach_child(parente:getChildren()[i])
end
end
end

for k , v in next ,children do

if #v:getChildren() < 1 then
node_list[v:getName()] = v
else
seach_child(v)
end
end
return node_list


end
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  cocos