消消方块阵换皮表情
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

32 lines
753 B

import { _decorator, Component, Node } from 'cc';
const { ccclass, property } = _decorator;
@ccclass('ClickActiveNode')
export class ClickActiveNode extends Component {
@property(Node)
targetNode: Node = null;
@property
active: boolean = true;
protected onEnable(): void {
this.node.on(Node.EventType.TOUCH_START, this.onTouchStart, this);
}
protected onDisable(): void {
this.node.off(Node.EventType.TOUCH_START, this.onTouchStart, this);
}
private onTouchStart(): void {
if (this.targetNode) {
if (this.active) {
this.targetNode.active = this.active;
} else
this.targetNode.active = !this.targetNode.active;
}
}
}