cc.Class({ extends: cc.Component, properties: { label:{type:cc.Label,default:null},//可以找属性检查器中赋值 组件和节点都可以 text:'hello' }, start () { this.label.string = this.text var a = this.node //获取到当前节点 a.x = 100 var can = this.getComponent(cc.Canvas) can = this.getComponent("Canvas") can = this.node.getComponent(cc.Canvas) var nodes = this.node.children //获取节点下的所有子节点 console.log("数量:" + nodes.length) var node = this.node.getChildByName("NodeName")//根据名字查找子节点 var node2 = cc.find("NodeName/Xixi",this.node) //在指定节点下查找子节点 var node3 = cc.find("Canvas/NodeName") //从根节点开始全局查找 }, });