物理射线 求救。。。

ver:1.9.1
manager.rayCast(p1, p2, cc.RayCastType.Closest); 这个p1 p2是 发射的起点坐标和终点坐标吧


各个坐标我打log都对,画出来的线怎么偏离了好远呢。。

       this.ctx.clear();
       let touchPos = event.getLocation(); //点击触摸的点
       let touchX = touchPos.x;
       let touchY = touchPos.y;
        console.log("touchPosx ===" + touchPos.x);
        console.log("touchPosy ===" + touchPos.y);
        let touchPosRadius = touchY / (touchX  - this.rayCastPos.x);
        this.p2x = this.width;
        this.p2y = touchPosRadius * (this.width - this.rayCastPos.x);//以上是求起始点和触摸点连线的延长线对应的边缘的位置
        this.rayCast(this.rayCastPos, cc.v2(this.p2x, this.p2y));

冥冥之中------------

第一个问题:坐标系问题!坐标系是相同的情况下!

第二个问题:节点关系!

第三个问题:算法逻辑!