2
0

Game1.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. using System;
  2. using System.Collections.Generic;
  3. #if ANDROID
  4. using Android.App;
  5. #endif
  6. using Microsoft.Xna.Framework;
  7. using Microsoft.Xna.Framework.Content;
  8. using Microsoft.Xna.Framework.Graphics;
  9. using Microsoft.Xna.Framework.Input;
  10. using Microsoft.Xna.Framework.Media;
  11. using Microsoft.Xna.Framework.Storage;
  12. namespace MonoGame.Samples.AdMob
  13. {
  14. /// <summary>
  15. /// This is the main type for your game
  16. /// </summary>
  17. public class Game1 : Microsoft.Xna.Framework.Game
  18. {
  19. GraphicsDeviceManager graphics;
  20. SpriteBatch spriteBatch;
  21. public Game1 ()
  22. {
  23. graphics = new GraphicsDeviceManager (this);
  24. Content.RootDirectory = "Content";
  25. graphics.PreferMultiSampling = true;
  26. graphics.IsFullScreen = true;
  27. graphics.SupportedOrientations = DisplayOrientation.LandscapeLeft | DisplayOrientation.LandscapeRight | DisplayOrientation.Portrait;
  28. }
  29. /// <summary>
  30. /// Allows the game to perform any initialization it needs to before starting to run.
  31. /// This is where it can query for any required services and load any non-graphic
  32. /// related content. Calling base.Initialize will enumerate through any components
  33. /// and initialize them as well.
  34. /// </summary>
  35. protected override void Initialize ()
  36. {
  37. // TODO: Add your initialization logic here
  38. base.Initialize ();
  39. }
  40. /// <summary>
  41. /// LoadContent will be called once per game and is the place to load
  42. /// all of your content.
  43. /// </summary>
  44. protected override void LoadContent ()
  45. {
  46. // Create a new SpriteBatch, which can be used to draw textures.
  47. spriteBatch = new SpriteBatch (GraphicsDevice);
  48. }
  49. /// <summary>
  50. /// Allows the game to run logic such as updating the world,
  51. /// checking for collisions, gathering input, and playing audio.
  52. /// </summary>
  53. /// <param name="gameTime">Provides a snapshot of timing values.</param>
  54. protected override void Update (GameTime gameTime)
  55. {
  56. if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
  57. {
  58. Exit();
  59. }
  60. base.Update (gameTime);
  61. }
  62. /// <summary>
  63. /// This is called when the game should draw itself.
  64. /// </summary>
  65. /// <param name="gameTime">Provides a snapshot of timing values.</param>
  66. protected override void Draw (GameTime gameTime)
  67. {
  68. graphics.GraphicsDevice.Clear (Color.CornflowerBlue);
  69. // Won't be visible until we hide the movie
  70. spriteBatch.Begin();
  71. spriteBatch.End();
  72. }
  73. }
  74. }