好的,我想要的是在gameState.gameLoading
之后将从窗口模式切换到全屏的代码,以便下一个gameState.mainMenu
状态为全屏。我怎么做?我的代码是:变量:
//Game States
public enum gameState
{
gameLoading,
mainMenu,
gameOptions,
levelSelect,
gamePlaying,
gameOver
}
gameState CurrentGameState = gameState.gameLoading;
Update()
方法:
if (CurrentGameState != gameState.gameLoading)
{
IsMouseVisible = false;
graphics.IsFullScreen = true;
}
if (CurrentGameState == gameState.gameLoading)
{
IsMouseVisible = true;
graphics.IsFullScreen = false;
}
但它不起作用。有什么建议吗?
答案 0 :(得分:1)
您需要应用图形更改,如下所示:
graphics.IsFullScreen = true;
graphics.ApplyChanges();
// profit
答案 1 :(得分:0)
Here您可以使用graphics.ToggleFullScreen()
检查您获得的例外情况。
答案 2 :(得分:0)
我找到的解决方案是:
//Update() method
if (CurrentGameState == gameState.gameLoading)
{
if (Keyboard.GetState().IsKeyDown(Keys.Enter))
{
graphics.ToggleFullScreen(); //?
}
graphics.ApplyChanges();
}