Get started with MonoGame in 5 easy steps

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.

Add-in ManagerScreenshot 2014-01-31 20.00.14

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.

Compile in Release modeDownloaded solution

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.

Creating a new solution

If you simply run the project, the compiler will complain that it cannot find the framework.

Unhandled Exception:
System.IO.FileNotFoundException: Could not load file or assembly 'MonoGame.Framework, Version=3.0.1.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies.
File name: 'MonoGame.Framework, Version=3.0.1.0, Culture=neutral, PublicKeyToken=null'
[ERROR] FATAL UNHANDLED EXCEPTION: System.IO.FileNotFoundException: Could not load file or assembly 'MonoGame.Framework, Version=3.0.1.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies.
File name: 'MonoGame.Framework, Version=3.0.1.0, Culture=neutral, PublicKeyToken=null'

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.

Screenshot 2014-01-31 20.15.01Screenshot 2014-01-31 20.16.09

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!

Moneys!

Advertisements

2 thoughts on “Get started with MonoGame in 5 easy steps

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s