当入侵者到达屏幕的最左侧时,我无法向下移动它们,但是当它们到达最右侧时,它们向下移动却没有问题。运动的代码如下所示:
if (Invaders[0].GetXPos() < 100) // if the first invader element riches the far left of the screen, change direction, and move down four pixels.
{
AlienDirection = +1;
for (int Count = 0; Count < 11; Count++)
{
Invaders[Count].MoveVertical(4);
}
}
if (Invaders[10].GetXPos() > 924)
{
AlienDirection = -1;
for (int Count = 0; Count < 11; Count++)
{
Invaders[Count].MoveVertical(4); // if the first invader element riches the far left of the screen, change direction, and move down four pixels.
}
}
我不知道是什么导致外星人在他们向左齿轮时不向下移动。谢谢你。