Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Building XNA 2.0 Games- P12: I would like to acknowledge John Sedlak, who saved this book from certain doom, as well as all of the great guys in the XNA community and Microsoft XNA team, who helped me with all of my stupid programming questions. (That is actually the term used—“stupid programming question”—and it is a question that one should not have to ask if one has been approached to write a book about the subject.) | 318 CHAPTER 10 MENUS A HUD AND DEPLOYMENT 1f - optionFrame i GetAlpha true 1f - optionFrame i -.1f new Vector2 160f 32f 1f SpriteEffects.None 1f sprite.End If we re not in dead mode draw the second layer of fog and foreground graphic if menuMode MenuMode.Dead sprite.Begin SpriteBlendMode.Additive pan 2f for int i 0 i fog.Length 2 i sprite.Draw spritesTex fog i new Vector2 pan 0f new Rectangle i 4 64 0 64 64 new Color new Vector4 1f 1f 1f .1f GetAlpha false fog i .X fog i .Y 100f new Vector2 32f 32f float i 10 .5f 2f SpriteEffects.None 1f sprite.End sprite.Begin SpriteBlendMode.AlphaBlend sprite.Draw poseForeTex new Vector2 Game1.ScreenSize.X - Game1.ScreenSize.Y 480f 616f GetAlpha false float Math.Cos double frame 20f 20f Game1.ScreenSize.Y - Game1.ScreenSize.Y 480f 286f new Rectangle 0 0 616 286 new Color new Vector4 GetAlpha false GetAlpha false GetAlpha false 1f 0f new Vector2 Game1.ScreenSize.Y 480f SpriteEffects.None 1f sprite.End CHAPTER 10 MENUS A HUD AND DEPLOYMENT 319 Options Population Now let s take a look at our PopulateOptions method. It s just a bunch of cases again. The only odd bit is for the main level if we re in pause mode our main level will be a bit different than for the other modes. private void PopulateOptions for int i 0 i option.Length i option i Option.None switch level case Level.Main if menuMode MenuMode.Pause option 0 Option.ResumeGame option 1 Option.EndGame option 2 Option.Options option 3 Option.Quit totalOptions 4 else option 0 Option.NewGame option 1 Option.Continue option 2 Option.Options option 3 Option.Quit totalOptions 4 break case Level.Options option 0 Option.Back totalOptions 1 break case Level.Dead option 0 Option.EndGame option 1 Option.Quit totalOptions 2 break default totalOptions 0 break 320 CHAPTER 10 MENUS A HUD AND DEPLOYMENT Pausing and Dying We ll be using the Pause and Die methods from elsewhere in our game to set all of the appropriate flags to pause or go into you-are-dead mode. public void Pause menuMode .