2012-01-13 67 views
2

我只想在菜單中創建一個簡單的啓動畫面,其中包含以下內容;如何在XNA 4.0中添加一個開始(splash)屏幕?

「按‘Enter’開始」 // 「指令」

(很明顯,當你在網頁上的指示是,應該有一個「點擊這裏要返回到主菜單選項」

我創建的遊戲是2D賽車遊戲(我還沒有在執行定時(DNO如何))

我試着在我的代碼來實現這一點; http://create.msdn.com/en-US/education/catalog/sample/game_state_management

乙我半小時後放棄了(太複雜了)

任何幫助都是值得歡迎的。謝謝!!!

回答

2

你可以採取的另一個行動是使用enum來存儲不同的遊戲狀態。在你畫法

GameState gameState = new GameState(); 
gameState = GameState.Menu; 

然後:

if(gameState == GameState.Menu) 
{ 
// Draw your menu, do other stuff for other gamestates. 
} 

最後的更新:

if(gameState == GameState.Menu) 
{ 
// check if keyboard is pressed and continue if it is 
} 
else if(gameState == GameState.Game) 
{ 
// Your main game update logic 
} 

希望這有助於

//Don't forget to put this above the Game1 class! 
public enum GameState 
{ 
    Menu, 
    Game, 
    Credits, 
    Etc 
} 

初始化它!