forked from MonoGame/MonoGame
-
Notifications
You must be signed in to change notification settings - Fork 0
Tutorials:creating a game class
dellis1972 edited this page Feb 10, 2012
·
5 revisions
This section explains how to integrate your main Game class in various supported platforms.
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using Microsoft.Xna;
using Microsoft.Xna.Samples;
using Microsoft.Xna.Samples.Draw2D;
namespace Microsoft.Xna.Samples.Draw2D
{
[Register ("AppDelegate")]
class Program : UIApplicationDelegate
{
private Game1 game;
public override void FinishedLaunching (UIApplication app)
{
// Fun begins..
game = new Game1();
game.Run();
}
static void Main (string [] args)
{
UIApplication.Main (args,null,"AppDelegate");
}
}
}
using Android.App;
using Android.OS;
using Microsoft.Xna.Framework;
namespace Microsoft.Xna.Samples.Draw2D
{
[Activity(Label = "Draw2D",
MainLauncher = true,
Icon ="@drawable/icon",
ConfigurationChanges=ConfigChanges.Orientation|ConfigChanges.Keyboard|ConfigChanges.KeyboardHidden)]
public class Activity1 : AndroidGameActivity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
Game1.Activity = this;
var g = new Game1();
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;
}
}
}
Back to Home