是的,我得到的游戏是2D赛车游戏。我在游戏中实现了终点线图像等等。我把它作为一个单独的精灵表。这是我试图以这种方式改变的代码,即'如果car1blue与finishLine1相交,则结束游戏。'但我似乎无法做到正确。这是我试图改变的代码;
if (IntersectPixels(destinationBlueRect, finishLine1TextureData, finishLine1Rectangle, finishLine1TextureData))
{
blueHit = true;
}
如果你能告诉我如何添加一个结束游戏消息,说“玩家1获胜”(当汽车越过终点线1)并在此之后大约三秒结束游戏,那会更好吗?
欢迎任何帮助(我是新手)。谢谢!
答案 0 :(得分:1)
您可能希望实施此Game State Management系统,至于您的延迟:
float delayTime = 3000;// Time to delay in milliseconds
float delayBuffer = 0;// This will count how much time has passed
// In your Update method
if (blueHit) {// You should change this to whatever way you find if someone has won the game
if (delayBuffer < delayTime) {
delayBuffer += (float)gameTime.ElapsedGameTime.TotalMilliseconds;
} else {
// Show the last screen
}
}