我的XNA项目遇到了一些困难;当主角移动到左角或右角时(分别转到下一级或上一级),我想更改级别。 但是,由于我似乎无法理解的问题,角色无法回到前一级别(请查看if player.Position.X == 1200语句 - 这种情况永远不会发生)。向前走似乎工作得很好。我有什么想法可能做错了吗?
private void UpdateLevelOne()
{
if (player.Position.X == 0)
{
showLevelOne = false;
showLevelTwo = true;
player.Position = new Vector2(1200, ground - player.Size.Height);
levelTwo.backgroundVector = new Vector2(-750,0);
}
}
private void UpdateLevelTwo()
{
if (player.Position.X <= 250)
{
showLevelTwo = false;
showLevelOne = true;
player.Position = new Vector2(1200, ground - player.Size.Height);
levelOne.backgroundVector = new Vector2(-750, 0);
}
if (player.Position.X == 1200)
{
showLevelTwo = false;
showLevelOne = true;
player.Position = new Vector2(10, ground - player.Size.Height);
}
}
答案 0 :(得分:4)
也许你应该试试
if (player.Position.X > 1200)
//Do Something