layabox Laya this.owner

分类栏目:layabox教程

210

this.owner可以获取目标所属的Node节点

如果一个组件类绑定到节点上面,可以通过 this.owner来获取绑定的节点。

获取一个节点的父亲节点,则使用 this.owner.parent

获取节点所在的场景 this.owner.scene

根据名称查找孩子节点,则使用 this.owner.getChildByName(“孩子name”);

通过索引查找孩子节点,则可以使用 this.owner.getChildAt(0) 获取第一个孩子

获取所有孩子的个数,this.owner.numChildren 就是所有孩子的个数

获取一个孩子节点的索引下标 this.owner.getChildIndex(childNode)返回孩子下标