这是我在打砖块中的球碰撞代码:
Rectangle intersection = Rectangle.Intersect(block.Rect2D, ball.BallRec);
if (intersection.Width > intersection.Height)
{
ball.yVel = -ball.yVel;
}
else if (intersection.Width < intersection.Height)
{
ball.xVel = -ball.xVel;
}
else
{
ball.xVel = -ball.xVel;
ball.yVel = -ball.yVel;
}
不幸的是,球有时会“融化”到积木中并奇怪地弹跳,尤其是在高速时。我该如何解决?