每当正方形与圆碰撞(在任何方向:北,南,东或西)时,我的代码都应该将分数提高1,但不会检测到碰撞。我确定该函数正在被调用,并且该函数似乎没有任何错误。有什么问题吗?
function collisionPoint()
{
if (playerRight == pointX && playerLeft == pointX - playerWidth && playerTop > pointTop - playerHeight && playerBottom < pointBottom + playerWidth)
{
score++;
}
if (playerLeft == pointX && playerRight == pointX + playerWidth && playerTop > pointTop - playerHeight && playerBottom < pointBottom + playerWidth)
{
score++;
}
if (playerTop == pointY && playerBottom == pointY - playerHeight && playerRight < pointRight + playerWidth && playerLeft > pointLeft + playerWidth)
{
score++;
}
if (playerBottom == pointY && playerTop == pointY + playerHeight && playerRight < pointRight + playerWidth && playerLeft > pointLeft + playerWidth)
{
score++;
}
}