I’m doing a research which should answer the question which game engine can be used cross platforms in a hybrid scenario. What I mean by that is for the kind of stuff I want to build I would like to offer to the user a catalog, a shopping cart (and other features in a classic naitve UI) and a game engine player that should allow user interaction as well. Switching between them should be easily possible.
My question is if MonoGame if able to run in such a way. And if so, maybe somebody can point out a sample somewhere. Or where to start.
This should be possible with monogame definitely.
On iOS the game is a View with a default ViewController. You can present your own native iOS UI etc, so a tick there.
On Android the game is an Activity, and you can pop other activities over it, so another tick there.
I’m back with good news. I have removed the previous post because most of it was outdated after I started looking deeper into the monogame code. Still would be great to build game engines for any view, not only for the main view.
Hopefully somebody will iterate on this idea and add that missing feature to the core product.
The way I’ve create it as a child controller with Xamarin.Forms is approximately like this:
public class MonogamePageRenderer : PageRenderer {
...
public override void ViewWillAppear(bool animated) {
base.ViewWillAppear(animated);
_game = new MyGame(_model);
_monogameController = game.Services.GetService<UIViewController>();
AddChildViewController(_monogameController);
ViewController.View.AddSubview(_monogameController.View);
_monogameController.DidMoveToParentViewController(ViewController);
}
public override void ViewWillDisappear(bool animated) {
base.ViewWillDisappear(animated);
if (_monogameController != null) {
_monogameController.WillMoveToParentViewController(null);
_monogameController.View.RemoveFromSuperview();
_monogameController.RemoveFromParentViewController();
}
if (_game != null) {
_game.Dispose();
}
}