画面/状態の 3 つすべてが正常に動作しますが、情報画面として機能する 4 つ目の画面を実装しました。これまでのところは問題ありませんが、ゲームを実行して「H」キーを押しても、画面が別の背景に変わりません (これまでに行ったこと)。以下はコードです:
public void UpdateInformation(GameTime currentTime)
{
if (Keyboard.GetState().IsKeyDown(Keys.H))
{
GameState = 4;
} // GAMESTATE 4 which is the instruction/Information screen.
}
これは update メソッドのゲーム ステートのコードです。
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キーはうまく反応し、ゲームを開始します. 4 つの状態/画面は「Gamestate」と互換性がありますか? ありがとうございました。