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'兼容? 谢谢。