cc.Class({ extends: cc.Component, properties: { }, onLoad() { this.node.on(cc.Node.EventType.TOUCH_START, () => { if (this.node.interactable) { this._setAllChildColor(this.node, new cc.Color(133, 133, 133, 255)); } }); this.node.on(cc.Node.EventType.TOUCH_END, () => { this._setAllChildColor(this.node, new cc.Color(255, 255, 255, 255)); }); this.node.on(cc.Node.EventType.TOUCH_CANCEL, () => { this._setAllChildColor(this.node, new cc.Color(255, 255, 255, 255)); }); }, _setAllChildColor(node, color) { if (node && node.active) { if (node.childrenCount > 0) { for (var i = 0; i < node.children.length; i++) { this._setAllChildColor(node.children[i], color); } } node.color = color; } }, onDestory() { this.node.off(cc.Node.EventType.TOUCH_START, this); this.node.off(cc.Node.EventType.TOUCH_END, this); this.node.off(cc.Node.EventType.TOUCH_CANCEL, this); } });