在带有ComponentLua节点嵌套时。Lua下调用重名函数会出Bug。请问该如何解决?
###示例
例如一个Scene中的节点的层级结构如下
MainScene
|----Parent
|----|----Child
其中Child为Parent的子节点。
声明两个ComponentLua对象如下
ParentCom.lua
local M = {}
function M:printSelf()
cc.log("This is Parent");
end
return M
ChildCom.lua
local M = {}
function M:printSelf()
print("This is Child");
end
return M
在主场景中如下方式调用,将两个Component附加到分别附加到父子节点上,然后调用父节点的parentCom:printSelf(),然而输出却是This is Child:
local root = self:getResourceNode()
local parent = root:getChildByName("Parent")
local child = parent:getChildByName("Child")
local parentCom = cc.ComponentLua:create("app/views/ParentCom.lua")
parentCom:setName("ParentComponent")
parent:addComponent(parentCom)
local childCom = cc.ComponentLua:create("app/views/ChildCom.lua")
childCom:setName("ChildComponent")
child:addComponent(childCom)
parentCom:printSelf()
是在Lua中Component并不常用吗?