CHAPTER 3 ■ WORKING WITH 2D IMAGES/TEXTURES IN XNA 3.0
197
menuList.Add(menuMain);
menuList.Add(menuNewGame);
menuMain.AddMenuItem("New Game", menuNewGame);
menuNewGame.AddMenuItem("Back to Main menu", menuMain);
menuMain.WakeUp();
This will create two menus, each containing an item that links to the other menu. After
you’re done initializing your menu structure, the mainMenu is activated, bringing it in the
Starting state.
Now you need to update all your menus during the update cycle of your program:
foreach (MenuWindow currentMenu in menuList)
currentMenu.Update(gameTime.ElapsedGameTime.TotalMilliseconds);
and render them during the draw phase of your program:
spriteBatch.Begin();
foreach (MenuWindow currentMenu in menuList)
currentMenu.Draw(spriteBatch); ...