cocosCreator this 与 this.node 区别

先说 为什么我们要用
var self = this;
因为作用域不同

在异步执行回调中 ,this的作用域已经变更,因此 在外部定义self有助于变量的引用

node 是组件最基本的属性
因此 如果我们定义的控件 为node类型
直接可以获取this.color

但是如果定义的是 label类型
这时就需要获取 this.node.color

此外这个控件可能还有很多其他属性
使用 getComponent 来获取 比如:
this.FCCLabel.getComponent(cc.Widget)
获取该组件上下左右..等等

你可能感兴趣的:(cocosCreator this 与 this.node 区别)