版本:3.3.2
在Mask节点上挂脚本监听事件。
start(): void {
this.graphics = this.getComponent(Graphics);
if (this.graphics == null) {
let mask = this.getComponent(Mask);
this.graphics = mask.graphics;
}
}
onEnable(): void {
this.target.on(Node.EventType.TOUCH_START, this.onTouchStart, this);
this.target.on(Node.EventType.TOUCH_MOVE, this.onTouchMove, this);
this.target.on(Node.EventType.TOUCH_END, this.onTouchEnd, this);
}
onDisable(): void {
this.target.off(Node.EventType.TOUCH_START, this.onTouchStart, this);
this.target.off(Node.EventType.TOUCH_MOVE, this.onTouchMove, this);
this.target.off(Node.EventType.TOUCH_END, this.onTouchEnd, this);
}
private onTouchStart(event: EventTouch): void {
let location = event.getUILocation();
let position = this.uitransfrom.convertToNodeSpaceAR(v3(location.x, location.y));
this.graphics.circle(position.x, position.y, this.radius);
this.graphics.fill();
}
private onTouchMove(event: EventTouch): void {
let location = event.getUILocation();
let position = this.uitransfrom.convertToNodeSpaceAR(v3(location.x, location.y));
this.graphics.circle(position.x, position.y, this.radius);
this.graphics.fill();
console.log("onTouchMove ", location);
}

Mask的type类型为graphics,inverted为true。
Node.EventType.TOUCH_MOVE没有事件回调。