MonoGame is the little brother of Mono: a small and cool platform for making (mostly) 2D games. It’s an open source implementation of XNA and is compatible with iOS, Android, Mac, MacOS, Linux and Windows 8 (support for more platforms is coming). If however, more complex and 3D games is your thing, you can head out to Unity3D, also in the Mono family.
1. Get MonoGame from CodePlex
Download the latest MonoGame version from Codeplex. The is are multiple versions: a Windows one, a MonoDevelop one and, finally, the one we need, the Xamarin version. They each come as an .mpack, which needs to be installed in the corresponding IDE.
2. Add it in Xamarin Studio via Add-in Manager
Click on the “Install from file” option in the Add-in Manager and chose the .mpack we downloaded earlier. You now should be able to see a new MonoGame category in the list, and under it MonoGame Project Templates. By clicking it, you can also see the Disable and Uninstall buttons, if you want to do so at a later time.
3. Download the MonoGame framework from GitHub
You don’t need to clone the repo, unless you plan to contribute to it :). You can simply download it as a .zip, where you should find a folder with a .sln for every platform that MonoGame supports.
4. Open the solution for the platform you need and build it in Release Mode
In the MonoGame.Framework folder, also contained in the .zip, navigate to the output directory (for example, MonoGame.Framework/bin/MacOS/Release) and find the resulted DLLs: MonoGame.Framework and Lidgren.Network.
Note: The compilation can generate some errors, but that’s OK.
5. Create the new game project. Remove old references and add in new DLLs
When creating a new solution, we now have the option to create a MonoGame project for the different supported platforms.
If you simply run the project, the compiler will complain that it cannot find the framework.
System.IO.FileNotFoundException: Could not load file or assembly ‘MonoGame.Framework, Version=188.8.131.52, Culture=neutral, PublicKeyToken=null’ or one of its dependencies.
File name: ‘MonoGame.Framework, Version=184.108.40.206, Culture=neutral, PublicKeyToken=null’
[ERROR] FATAL UNHANDLED EXCEPTION: System.IO.FileNotFoundException: Could not load file or assembly ‘MonoGame.Framework, Version=220.127.116.11, Culture=neutral, PublicKeyToken=null’ or one of its dependencies.
File name: ‘MonoGame.Framework, Version=18.104.22.168, Culture=neutral, PublicKeyToken=null'[/code]
We need to delete the old framework reference and add in the new DLLs we compiled in step 4: just double-click the References folder in the Solution window tab.
Ready to Game!
Now the project should run and you should see the following output, because the new project template contains sample graphics loading and drawing code. You can build upon this code or simply delete it. Have fun!