forked from MonoGame/MonoGame
-
Notifications
You must be signed in to change notification settings - Fork 5
HowToUse
Jorgemagic edited this page Apr 13, 2011
·
7 revisions
This section explains how to integrate your main Game class in various supported platforms.
#region Using Statements
using System;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using Microsoft.Xna;
using Microsoft.Xna.Framework.Media;
#endregion
namespace YourNamespace
{
[Register("AppDelegate")]
class Program : UIApplicationDelegate
{
public override void FinishedLaunching(UIApplication app)
{
// Fun begins..
using (Game1 game = new Game1())
{
game.Run();
}
}
/// <summary>
/// The main entry point for the application.
/// </summary>
static void Main(string[] args)
{
UIApplication.Main(args, null, "AppDelegate");
}
}
}using Android.App;
using Android.OS;
namespace Microsoft.Xna.Samples.Draw2D
{
[Activity(Label = "Draw2D", MainLauncher = true, Icon = "@drawable/icon")]
public class Activity1 : Activity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
var g = new Game1(this);
SetContentView(g.Window);
g.Run();
}
}
}using MonoMac.AppKit;
using MonoMac.Foundation;
namespace Microsoft.Xna.Samples.Draw2D
{
class Program
{
static void Main (string[] args)
{
NSApplication.Init ();
using (var p = new NSAutoreleasePool ()) {
NSApplication.SharedApplication.Delegate = new AppDelegate ();
// Set our Application Icon
NSImage appIcon = NSImage.ImageNamed ("monogameicon.png");
NSApplication.SharedApplication.ApplicationIconImage = appIcon;
NSApplication.Main (args);
}
}
}
class AppDelegate : NSApplicationDelegate
{
private Game1 game;
public override void FinishedLaunching (MonoMac.Foundation.NSObject notification)
{
game = new Game1 ();
game.Run ();
}
public override bool ApplicationShouldTerminateAfterLastWindowClosed (NSApplication sender)
{
return true;
}
}
}