文档中碰撞点击测试在使用摄像机的情况下坐标转换问题

照着官方例子写的,如下:
cc.eventManager.addListener({
event: cc.EventListener.TOUCH_ONE_BY_ONE,
onTouchBegan: (touch, event) => {
var touchLoc = touch.getLocation();
if (cc.Intersection.pointInPolygon(touchLoc, this.polygonCollider.world.points)) {
this.title.string = ‘Hit’;
}
else {
this.title.string = ‘Not hit’;
}
return true;
},
}, this.node);
发现touch.getLocation()的值没有根据摄像机的移动和缩放变化。导致点击测试不准确,几乎都是not hit。。

@jare 大神···求救

需要用新添加的这个函数转换一下 touch 坐标,不过这个还没发布,可能会放在 1.5.2 中
https://github.com/cocos-creator/engine/pull/1720/files#diff-963a86be9a74bf34b892cc91e5cc3d25R249

ok 按你说的解决了··