main.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #if MONOMAC
  2. using MonoMac.AppKit;
  3. using MonoMac.Foundation;
  4. #elif IPHONE
  5. using MonoTouch.Foundation;
  6. using MonoTouch.UIKit;
  7. #endif
  8. namespace Microsoft.Xna.Samples.BouncingBox
  9. {
  10. #if MONOMAC
  11. class Program
  12. {
  13. static void Main (string[] args)
  14. {
  15. NSApplication.Init ();
  16. using (var p = new NSAutoreleasePool ()) {
  17. NSApplication.SharedApplication.Delegate = new AppDelegate ();
  18. // Set our Application Icon
  19. NSImage appIcon = NSImage.ImageNamed ("monogameicon.png");
  20. NSApplication.SharedApplication.ApplicationIconImage = appIcon;
  21. NSApplication.Main (args);
  22. }
  23. }
  24. }
  25. class AppDelegate : NSApplicationDelegate
  26. {
  27. private Game1 game;
  28. public override void FinishedLaunching (MonoMac.Foundation.NSObject notification)
  29. {
  30. game = new Game1 ();
  31. game.Run();
  32. }
  33. public override bool ApplicationShouldTerminateAfterLastWindowClosed (NSApplication sender)
  34. {
  35. return true;
  36. }
  37. }
  38. #elif IPHONE
  39. [Register ("AppDelegate")]
  40. class Program : UIApplicationDelegate
  41. {
  42. private Game1 game;
  43. public override void FinishedLaunching (UIApplication app)
  44. {
  45. // Fun begins..
  46. game = new Game1();
  47. game.Run();
  48. }
  49. static void Main (string [] args)
  50. {
  51. UIApplication.Main (args,null,"AppDelegate");
  52. }
  53. }
  54. #endif
  55. }