// 节点常用属性方法
// 获取子节点[0]就是第几个子节点
this.node.children[0]
this.node.getChildrenByName('abc')//通过名称
// 通过路径
cc.find('Canvas/Main Camera')
// 获得父节点
this.node.getParent()
this.node.setParent('ddd')//设置父节点
this.node.removeAllChildren()//移除所有节点
this,node.removeChildren(ddd)
this.node.removeFromParent()//移除父节点
// 访问位置
this.node.x
this.node.y
// this.node.setPosition(3,4)
this.node.setParent(cc.v2(3,4))
// 旋转
this.node.rotation
// 缩放
// 锚点
// 颜色 this.node.color =cc.Color.RED
// 节点开关
this.node.actIve =false
// 组件开关
// this.enabled = false
// 获取组件
let sprite = this.getComponent(cc.Sprite)//加s是数组
sprite.enabled
// 获取子物体 精灵类型的组件 获取不到一半是null
this.getComponentInChildren(cc.Sprite)
cocos2d 节点属性方法
最新推荐文章于 2025-03-18 13:39:37 发布