Search code examples
c#xamarinxamarin.androidcocossharpurhosharp

Can Xamarin.Android be used to develop Android games?


I have successfully developed an iOS game with Xamarin.iOS.

Now, would someone please tell me if Xamarin.Android can be used to develop Android games ? On Xamarin website, when I search for samples of games for Xamarin.Android, I can only see samples of games developed with cross platforms tools such as MonoGame, CocosSharp, and UrhoSharp. I see no samples codes for games specifically developed with the Xamarin.Android framework.

Please tell me: can Xamarin.Android be used to develop games? Or is it true that Xamarin.Android can't be used to develop Android games, and, instead, we have to use other tools listed on Xamarin website such as MonoGame, CocosSharp, and UrhoSharp to develop games for Android devices ?

Thank you very much.


Solution

  • Yes, Xamarin.Android can be used to develop an Android game. Even though it might not look like so, Xamarin.Android is still working behind the scenes when using for example UrhoSharp.

    Check out UrhoSharp samples and you can see how the Android sample has the familiar MainActivity class with lots of Xamarin.Android stuff going on.

    Same with MonoGame. You still need to have the main launcher defined and the Android app lifecycle stuff handled. Here's the Activity class from a MonoGame sample.

    To get even a better idea of how things work, here are some details of how MonoGame and Xamarin.Android work hand in hand:

    1. All MonoGame games for Xamarin.Android create a specific type of Activity called AndroidGameActivity.
    2. AndroidGameActivity contains the MonoGame's Game object that handles content, updating, rendering and other stuff. That is all MonoGame specific.
    3. The AndroidGameActivity handles the basic activity lifecycle methods like OnPause and OnResume. This is all Xamarin.Android specific.

    It's worth noting that you don't necessarily need any of the game engines/frameworks to develop a game using Xamarin.Android. You could for example build a strategy game that only uses Android UI controls, or maybe a text game that only needs an EditText and a TextView controls.

    You can also draw some simple 2D shapes, but to build a more complex game something like OpenGL is needed. That's when MonoGame, UrhoSharp and other libraries come into play.