public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions) { if(Game == null) throw new InvalidOperationException("Please set 'Game' to a valid instance of Game before calling this method."); var bounds = UIScreen.MainScreen.Bounds; // create the game main windows MainWindow = new UIWindow(bounds); // create the xenko game view var xenkoGameView = new iOSXenkoView((RectangleF)bounds) {ContentScaleFactor = UIScreen.MainScreen.Scale}; // create the view controller used to display the xenko game var xenkoGameController = new XenkoGameController { View = xenkoGameView }; // create the game context var gameContext = new GameContextiOS(new iOSWindow(MainWindow, xenkoGameView, xenkoGameController)); // Force fullscreen UIApplication.SharedApplication.SetStatusBarHidden(true, false); // Added UINavigationController to switch between UIViewController because the game is killed if the FinishedLaunching (in the AppDelegate) method doesn't return true in 10 sec. var navigationController = new UINavigationController {NavigationBarHidden = true}; navigationController.PushViewController(gameContext.Control.GameViewController, false); MainWindow.RootViewController = navigationController; // launch the main window MainWindow.MakeKeyAndVisible(); // launch the game Game.Run(gameContext); return Game.IsRunning; }
/// <summary> /// Initializes a new instance of the <see cref="GameContext" /> class. /// </summary> /// <param name="mainWindows">The main windows of the game</param> /// <param name="gameView">The view in which the game is rendered</param> /// <param name="gameViewController">The xenko game main controller</param> /// <param name="requestedWidth">Width of the requested.</param> /// <param name="requestedHeight">Height of the requested.</param> public GameContext(UIWindow mainWindows, iPhoneOSGameView gameView, XenkoGameController gameViewController, int requestedWidth = 0, int requestedHeight = 0) { MainWindow = mainWindows; GameView = gameView; GameViewController = gameViewController; RequestedWidth = requestedWidth; RequestedHeight = requestedHeight; ContextType = AppContextType.iOS; }
/// <summary> /// Initializes a new instance of the <see cref="GameContext" /> class. /// </summary> /// <param name="mainWindows">The main windows of the game</param> /// <param name="gameView">The view in which the game is rendered</param> /// <param name="gameViewController">The xenko game main controller</param> /// <param name="requestedWidth">Width of the requested.</param> /// <param name="requestedHeight">Height of the requested.</param> public GameContext(UIWindow mainWindows, iPhoneOSGameView gameView, XenkoGameController gameViewController, int requestedWidth = 0, int requestedHeight = 0) { MainWindow = mainWindows; GameView = gameView; GameViewController = gameViewController; RequestedWidth = requestedWidth; RequestedHeight = requestedHeight; ContextType = AppContextType.iOS; }
/// <summary> /// Initializes current struct with a UIWindow <paramref name="w"/>, a GameView <paramref name="g"/>and a controller <paramref name="c"/>. /// </summary> public iOSWindow(UIWindow w, iPhoneOSGameView g, XenkoGameController c) { MainWindow = w; GameView = g; GameViewController = c; }
/// <summary> /// Initializes current struct with a UIWindow <paramref name="w"/>, a GameView <paramref name="g"/>and a controller <paramref name="c"/>. /// </summary> public iOSWindow(UIWindow w, iPhoneOSGameView g, XenkoGameController c) { MainWindow = w; GameView = g; GameViewController = c; }