Example #1
0
        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);
        }
Example #2
0
        public PointeriOS(InputSourceiOS source, iOSWindow uiControl, XenkoGameController gameController)
        {
            Source              = source;
            this.uiControl      = uiControl;
            this.gameController = gameController;
            var window = uiControl.MainWindow;

            window.UserInteractionEnabled            = true;
            window.MultipleTouchEnabled              = true;
            uiControl.GameView.MultipleTouchEnabled  = true;
            gameController.TouchesBeganDelegate     += Touched;
            gameController.TouchesMovedDelegate     += Touched;
            gameController.TouchesEndedDelegate     += Touched;
            gameController.TouchesCancelledDelegate += Touched;
            uiControl.GameView.Resize += OnResize;

            OnResize(null, EventArgs.Empty);
        }