BackgroundScreen.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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.Linq;
  10. using System.Text;
  11. using Microsoft.Xna.Framework.Graphics;
  12. using Microsoft.Xna.Framework;
  13. using GameStateManagement;
  14. namespace CatapultGame
  15. {
  16. class BackgroundScreen : GameScreen
  17. {
  18. Texture2D background;
  19. public BackgroundScreen()
  20. {
  21. TransitionOnTime = TimeSpan.FromSeconds(0.0);
  22. TransitionOffTime = TimeSpan.FromSeconds(0.5);
  23. }
  24. public override void LoadContent()
  25. {
  26. background = Load<Texture2D>("Textures/Backgrounds/title_screen");
  27. }
  28. /// <summary>
  29. /// Updates the background screen. Unlike most screens, this should not
  30. /// transition off even if it has been covered by another screen: it is
  31. /// supposed to be covered, after all! This overload forces the
  32. /// coveredByOtherScreen parameter to false in order to stop the base
  33. /// Update method wanting to transition off.
  34. /// </summary>
  35. public override void Update(GameTime gameTime, bool otherScreenHasFocus,
  36. bool coveredByOtherScreen)
  37. {
  38. base.Update(gameTime, otherScreenHasFocus, false);
  39. }
  40. public override void Draw(GameTime gameTime)
  41. {
  42. SpriteBatch spriteBatch = ScreenManager.SpriteBatch;
  43. spriteBatch.Begin();
  44. // Draw Background
  45. spriteBatch.Draw(background, new Vector2(0, 0),
  46. new Color(255, 255, 255, TransitionAlpha));
  47. spriteBatch.End();
  48. }
  49. }
  50. }