0
我的三個屏幕/狀態都正常工作,但是,我實現了第四個屏幕作爲信息屏幕。到目前爲止,但是當我運行遊戲並按下'H'鍵時,它不會將屏幕更改爲另一個背景(至今我所做的)。下面是代碼:Gamestate運行不正常
public void UpdateInformation(GameTime currentTime)
{
if (Keyboard.GetState().IsKeyDown(Keys.H))
{
GameState = 4;
} // GAMESTATE 4 which is the instruction/Information screen.
}
這是在更新方法的遊戲狀態代碼:
protected override void Update(GameTime gameTime)
{
switch (GameState)
{
case 1: UpdateStarted(gameTime);
break;
case 2: UpdatePlaying(gameTime);
break;
case 3: UpdateEnded(gameTime);
break;
case 4: UpdateInformation(gameTime);
break;
}
base.Update(gameTime);
}
我在這裏繪製畫面。
public void DrawInformation(GameTime currentTime)
{
spriteBatch.Begin();
spriteBatch.Draw(InfoBackground, Vector2.Zero, Color.White);
spriteBatch.End();
}
下面是狀態抽獎信息代碼:
protected override void Draw(GameTime gameTime)
{
switch (GameState)
{
case 1: DrawStarted(gameTime);
break;
case 2: DrawPlaying(gameTime);
break;
case 3: DrawEnded(gameTime);
break;
case 4: DrawInformation(gameTime);
break;
}
}
我希望這可以幫助,這只是我的H鍵沒有響應,但我的S鍵反應良好,並開始遊戲。四個狀態/屏幕是否與'Gamestate'兼容? 謝謝。