我正在使用actionscript 3開發Flash遊戲。它就像迷宮遊戲一樣。我們有一條船和繩索創建路徑。我遇到了碰撞問題。在通過該路徑時,它正確地碰撞到X軸& Y軸上,並且其工作正常,但是當它在任何角落(其中X軸與Y軸相遇)碰撞時,它只是穿過繩索。 這是我的碰撞腳本。ActionScript 3碰撞
if (leftArrow)
{
boat.x -= speed;
if(rope.hitTestPoint(boat.x,boat.y,true)){
boat.x += 5;
}
if(rope.hitTestPoint(boat.x,boat.y+height,true)){
boat.x += 5;
}
}
else if (rightArrow)
{
boat.x += speed;
if(rope.hitTestPoint(boat.x+boat.width,boat.y,true)){
boat.x -= 5;
}
if(rope.hitTestPoint(boat.x+boat.width,boat.y+height,true)){
boat.x -= 5;
}
}
else if (upArrow)
{
boat.y -= speed;
if(rope.hitTestPoint(boat.x,boat.y,true)){
boat.y += 5;
}
if(rope.hitTestPoint(boat.x+boat.width,boat.y,true)){
boat.y += 5;
}
}
else if (downArrow)
{
boat.y += speed;
if(rope.hitTestPoint(boat.x,boat.y+boat.height,true)){
boat.y -= 5;
}
if(rope.hitTestPoint(boat.x+boat.width,boat.y+boat.height,true)){
boat.y -= 5;
}
}