1234567891011121314151617181920212223242526272829303132333435363738394041 |
- cc.Class({
- extends: cc.Component,
- properties: {
- },
- onLoad() {
- this.node.on(cc.Node.EventType.TOUCH_START, () => {
- 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);
- }
- });
|