求助这个方法怎么调用

update(dt: number) {

// 获取敌人和箭头的位置

// 检查敌人是否在屏幕外 // 计算交点位置

const enemyPos=this.enemy.getWorldPosition()

    const intersection = this.CalculateIntersectionBetter(enemyPos.x, enemyPos.y,750,1334);

    //console.log(375,667)

    // 更新箭头指示的位置

    this.node.position =v3(intersection.x+this.pos.x,intersection.y+this.pos.y) ;



}

CalculateIntersectionBetter(x: number,  y: number, width: number, height: number)

{

    let worldPosition = new Vec2();

    let aspectRatio = height / width;

    let relativeY = y - height / 2;

    let relativeX = x - width / 2;

    let k = Math.floor(relativeY /relativeX);//GetSafeFloatDivisor : return value = value == 0 ? 0.01f : value;

    if (y > height / 2)

    {

        if (x < width / 2)

        {

            if (-aspectRatio < k)   //1

            {

                worldPosition.x = 0;

                worldPosition.y = height / 2 + (y - (height / 2)) * (width / 2) / (width / 2 - x);

            }

            else                    //2

            {

                worldPosition.x = width / 2 + (x - (width / 2)) * (height / 2) / (y - height / 2);

                worldPosition.y = height;

            }

        }

        else

        {

            if (aspectRatio < k)    //3

            {

                worldPosition.x = width / 2 + (x - (width / 2)) * (height / 2) / (y - height / 2);

                worldPosition.y = height;

            }

            else                    //4

            {

                worldPosition.x = width;

                worldPosition.y = height / 2 + (y - (height / 2)) * (width / 2) / (x - width / 2);

            }

        }

    }

    else

    {

        if (x > width / 2)

        {

            if (-aspectRatio < k)   //5

            {

                worldPosition.x = width;

                worldPosition.y = height / 2 + (y - (height / 2)) * (width / 2) / (x - width / 2);

            }

            else                    //6

            {

                worldPosition.y = 0;

                worldPosition.x = width / 2 + (x - (width / 2)) * (height / 2) / (height / 2 - y);

            }

        }

        else

        {

            if (aspectRatio < k)    //7

            {

                worldPosition.y = 0;

                worldPosition.x = width / 2 + (x - (width / 2)) * (height / 2) / (height / 2 - y);

            }

            else                    //8

            {

                worldPosition.x = 0;

                worldPosition.y = height / 2 + (y - (height / 2)) * (width / 2) / (width / 2 - x);

            }

        }

    }

    return worldPosition;

}

}

没看懂。。。。

这不是我自己写的代码,是我自己把unity转cocos的代码
不知道x和y要传入敌人的什么坐标

可能是 enemy 在 这个区域内 [750,1334] 的坐标. 注释里的 1,2,3,4,5,6,7,8, 好像是方向?

750,1334 像是设计分辨率.