MainActivity.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. using Android.App;
  2. using Android.Content.PM;
  3. using Android.Widget;
  4. using Android.OS;
  5. using Android.Views;
  6. using AtomicEngine;
  7. using AtomicBlaster;
  8. namespace AtomicPlayer
  9. {
  10. [Activity(Label = "AtomicPlayer", MainLauncher = true,
  11. Icon = "@drawable/icon", Theme = "@android:style/Theme.NoTitleBar.Fullscreen",
  12. ConfigurationChanges = ConfigChanges.KeyboardHidden | ConfigChanges.Orientation,
  13. ScreenOrientation = ScreenOrientation.Landscape)]
  14. public class MainActivity : Activity
  15. {
  16. protected override void OnCreate(Bundle bundle)
  17. {
  18. base.OnCreate(bundle);
  19. var mLayout = new AbsoluteLayout(this);
  20. var surface = AndroidSDLSurface.CreateSurface(this, false, typeof(GameRoot));
  21. mLayout.AddView(surface);
  22. SetContentView(mLayout);
  23. }
  24. protected override void OnResume()
  25. {
  26. AndroidSDLSurface.OnResume();
  27. base.OnResume();
  28. }
  29. protected override void OnPause()
  30. {
  31. AndroidSDLSurface.OnPause();
  32. base.OnPause();
  33. }
  34. public override void OnLowMemory()
  35. {
  36. AndroidSDLSurface.OnLowMemory();
  37. base.OnLowMemory();
  38. }
  39. protected override void OnDestroy()
  40. {
  41. AndroidSDLSurface.OnDestroy();
  42. base.OnDestroy();
  43. }
  44. public override bool DispatchKeyEvent(KeyEvent e)
  45. {
  46. if (!AndroidSDLSurface.DispatchKeyEvent(e))
  47. return false;
  48. return base.DispatchKeyEvent(e);
  49. }
  50. public override void OnWindowFocusChanged(bool hasFocus)
  51. {
  52. AndroidSDLSurface.OnWindowFocusChanged(hasFocus);
  53. base.OnWindowFocusChanged(hasFocus);
  54. }
  55. }
  56. }