我目前正在开发与“Breakout”类似的游戏。我遇到的问题是,每当球越过砖块的边缘时,它既不会移除砖块,也不会改变球的方向。
if (ball.Left > l.Left && (ball.Left + ball.Width) < l.Left-margin + l.Width)
{
if (ball.Top > l.Height && ball.Top < l.Top)
{
this.Controls.Remove(l);
ballDX *= -1;
ballDY *= -1;
}
else if (ball.Top < l.Height && ball.Top > l.Bottom)
{
this.Controls.Remove(l);
ballDX *= +1;
ballDY *= +1;
}
}