MainActivity.cs 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using System;
  2. using Android.App;
  3. using Android.Content;
  4. using Android.Runtime;
  5. using Android.Views;
  6. using Android.Widget;
  7. using Android.OS;
  8. using Microsoft.Xna.Framework;
  9. using Android.Content.PM;
  10. namespace CatapultGame.Android
  11. {
  12. [Activity(
  13. Label = "@string/app_name",
  14. MainLauncher = true,
  15. Icon = "@drawable/icon",
  16. AlwaysRetainTaskState = true,
  17. LaunchMode = LaunchMode.SingleInstance,
  18. ScreenOrientation = ScreenOrientation.SensorLandscape,
  19. ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.Keyboard | ConfigChanges.KeyboardHidden
  20. )]
  21. public class MainActivity : AndroidGameActivity
  22. {
  23. private CatapultGame _game;
  24. private View _view;
  25. protected override void OnCreate(Bundle bundle)
  26. {
  27. base.OnCreate(bundle);
  28. _game = new CatapultGame();
  29. _view = _game.Services.GetService(typeof(View)) as View;
  30. SetContentView(_view);
  31. _game.Run();
  32. }
  33. }
  34. }