BackgroundScreen.cs 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #region File Description
  2. //-----------------------------------------------------------------------------
  3. // BackgroundScreen.cs
  4. //
  5. // Microsoft XNA Community Game Platform
  6. // Copyright (C) Microsoft Corporation. All rights reserved.
  7. //-----------------------------------------------------------------------------
  8. #endregion
  9. #region Using Statements
  10. using System;
  11. using System.Collections.Generic;
  12. using System.Text;
  13. using GameStateManagement;
  14. using Microsoft.Xna.Framework.Graphics;
  15. using Microsoft.Xna.Framework;
  16. #endregion
  17. namespace Blackjack
  18. {
  19. class BackgroundScreen : GameScreen
  20. {
  21. Texture2D background;
  22. Rectangle safeArea;
  23. /// <summary>
  24. /// Initializes a new instance of the screen.
  25. /// </summary>
  26. public BackgroundScreen()
  27. {
  28. TransitionOnTime = TimeSpan.FromSeconds(0.0);
  29. TransitionOffTime = TimeSpan.FromSeconds(0.5);
  30. }
  31. #region Loading
  32. /// <summary>
  33. /// Load graphics content for the screen.
  34. /// </summary>
  35. public override void LoadContent()
  36. {
  37. background = ScreenManager.Game.Content.Load<Texture2D>(@"Images\titlescreen");
  38. safeArea = ScreenManager.Game.GraphicsDevice.Viewport.TitleSafeArea;
  39. base.LoadContent();
  40. }
  41. #endregion
  42. #region Update and Render
  43. /// <summary>
  44. /// Allows the screen to run logic, such as updating the transition position.
  45. /// Unlike HandleInput, this method is called regardless of whether the screen
  46. /// is active, hidden, or in the middle of a transition.
  47. /// </summary>
  48. /// <param name="gameTime"></param>
  49. /// <param name="otherScreenHasFocus"></param>
  50. /// <param name="coveredByOtherScreen"></param>
  51. public override void Update(GameTime gameTime, bool otherScreenHasFocus,
  52. bool coveredByOtherScreen)
  53. {
  54. base.Update(gameTime, otherScreenHasFocus, false);
  55. }
  56. /// <summary>
  57. /// This is called when the screen should draw itself.
  58. /// </summary>
  59. /// <param name="gameTime"></param>
  60. public override void Draw(Microsoft.Xna.Framework.GameTime gameTime)
  61. {
  62. ScreenManager.SpriteBatch.Begin();
  63. ScreenManager.SpriteBatch.Draw(background, ScreenManager.GraphicsDevice.Viewport.Bounds,
  64. Color.White * TransitionAlpha);
  65. ScreenManager.SpriteBatch.End();
  66. base.Draw(gameTime);
  67. }
  68. #endregion
  69. }
  70. }