我試圖讓遊戲全屏按下F按鈕,但它不起作用,我在想,因爲它必須先爲它重新加載應用程序採取影響,那麼我該怎麼做?如何使XNA應用程序自行重新加載
代碼:
public Game1()
{
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
IsMouseVisible = true;
graphics.PreferredBackBufferWidth = WINDOW_WIDTH;
graphics.PreferredBackBufferHeight = WINDOW_HEIGHT;
}
protected override void Update(GameTime gameTime)
{
// Allows the game to exit
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
this.Exit();
if (keyboard.IsKeyDown(Keys.F))
{
WINDOW_WIDTH = 1280;
WINDOW_HEIGHT = 720;
}
base.Update(gameTime);
}
每秒做60次可能不是那麼明智。考慮將鍵盤狀態存儲在更新結束時的屬性(PreviousKeyboardState)中(僅在base.update之前,但在所有其他邏輯之後),並確保用戶沒有通過檢查PreviousKeyboardState.IsKeyUp(Keys鍵)來按住f鍵。 F) –
我該怎麼做?我用鼠標點擊了同樣的東西,但是如何通過點擊按鈕來完成呢? – YayCoding