在 swift 中画一条假想线

Draw a hypothetical line in swift

所以在我的游戏中有这个球拍和一个球,我想计算球击中球拍的哪一侧,我在 C# 中找到了这个答案,它显示了画两条线,如下所示:

所以我想做的是画两条假想线(意思是用户看不到),这样我就可以计算出球是否大于两条线,或者它是否与球拍的一侧接触。

如何在 sprite kit 和 swift 中绘制这些线条?

更新

我找到了原来的答案,HERE

您可以检查球相对于球拍的位置。

If(ballNode.position.x > paddleNode.position.x) {
    // ball is on the right of the paddle
} else {
    // ball is on the left of the paddle
}

If(ballNode.position.y > paddleNode.position.y) {
    // ball is above the paddle
} else {
    // ball is below the paddle
}