BackgroundScreen.cs 2.5 KB

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