Touch(屏幕坐标非游戏坐标)

getLocation x轴为相对设计尺寸左下角距离

getLocationInView x轴为相对视窗左侧距离,y轴为相对视窗中心距离

getUILocation 游戏中相对左下角xy距离的坐标(若屏幕无缩放则与getLocation)无差异

Node:

getLocation为相对锚点坐标

getWorldPosition为锚点相对左下角坐标

console.log("设计尺寸左下(不被缩放影响):" + event.getLocation());
console.log("设计尺寸左上(被缩放影响):" + event.getLocationInView());
console.log("渲染视图左下(被缩放影响):" + event.getUILocation());

console.log("节点世界坐标:" + this.node.parent.getWorldPosition());
console.log("节点坐标:" + this.node.parent.getPosition());

图1

this.body.on(NodeEventType.TOUCH_START, (event: EventTouch) => {
    console.log("getLocation:" + event.getLocation());
    console.log("getLocationInView" + event.getLocationInView());
    let node: Node = event.target
    console.log("Node getLocation:" + node.getPosition());
    console.log("Node getWorldPosition" + node.getWorldPosition());
}
             
// 输出
getLocation:(940.00, 604.00)
getLocationInView(940.00, 730.00)
Node getLocation:(0.00, 0.00, 0.00)
Node getWorldPosition(477.33, 329.55, 0.00)