I'm creating a CocosSharp game with several additional native screens which I'm going to implement using native iOS UIViewController. The flow is the following:
On app startup I'm creating UINavigationViewController and initial view with my custom main menu:
public override void FinishedLaunching(UIApplication app) { MainWindow = new UIWindow(UIScreen.MainScreen.Bounds); var rootViewStoryboard = UIStoryboard.FromName("GameMenu", null); var rootView = rootViewStoryboard.InstantiateViewController("GameMenu"); var navigationController = new UINavigationController(rootView); MainWindow.RootViewController = navigationController; MainWindow.MakeKeyAndVisible(); } public partial class GameMenu : UIViewController { public GameMenu(IntPtr handle) : base(handle) { } public override void ViewDidLoad() { base.ViewDidLoad(); btnStartGame.TouchUpInside += (sender, e) => NavigationController.PresentViewController(new GameScene(), false); } }
One of the actions leads to another UIViewController (modal) where CocosSharp game is created:
public partial class GameScene : UIViewController { public GameScene() { }
public override void ViewDidLoad() { base.ViewDidLoad(); _application = new CCApplication(); _application.ApplicationDelegate = new GameAppDelegate(); _application.StartGame(); _application.MainWindow.DisplayStats = true; OnStopGame(); }
}
Finally on certain event (in my case in 5 sec) I'm trying to finish a game and return back to the main menu:
public async Task OnStopGame() { await Task.Delay(5000); _application.ExitGame(); NavigationController.DismissViewController(false, null); }
As a result I get empty black screen, background music continue to run, no main menu is displayed.
How should I properly navigate from CocosSharp game to a native controller and back? Can they live in parallel?