2
0

AdMobGame.cs 2.4 KB

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