cocos 屏幕点击坐标转换为节点坐标
this.onN(this.node, Node.EventType.TOUCH_END, (e: EventTouch) => {
// 获取触摸点,转为Canvas画布上的坐标
let locatPos: Vec2 = e.getLocation()
let posInCamera = App.uiManager.uiCamera.screenToWorld(new Vec3(locatPos.x, locatPos.y, 0))
let pos = this.stepNode.parent!.getComponent(UITransform)!.convertToNodeSpaceAR(posInCamera)
let pos2d = new Vec2(pos.x, pos.y)
let rect = this.stepNode.getComponent(UITransform)!.getBoundingBox();
// 判断触摸点是否在按钮上
if (rect.contains(pos2d)) {
e.preventSwallow = true
Log.d('点击了按钮')
}
})