CHAPTER 3 ■ WORKING WITH 2D IMAGES/TEXTURES IN XNA 3.0
202
You can use this menusRunning variable to make sure you’re not updating/drawing your
menus when the user is in the game:
if (menusRunning)
{
spriteBatch.Begin(SpriteBlendMode.AlphaBlend,
➥
SpriteSortMode.BackToFront, SaveStateMode.None);
foreach (MenuWindow currentMenu in menuList)
currentMenu.Draw(spriteBatch);
spriteBatch.End();
Window.Title = "Menu running ...";
}
else
{
Window.Title = "Game running ...";
}
The Code
All the code is available for download at www.apress.com.
The MenuWindow Class
Here are some easy and necessary methods:
public MenuWindow(SpriteFont spriteFont, string menuTitle,
➥
Texture2D backgroundImage)
{
itemList = new List<MenuItem>();
changeSpan = TimeSpan.FromMilliseconds(800); ...