You currently have JavaScript disabled on your browser.

This website uses JavaScript, and This page needs JavaScript activated to work correctly.

Please active JavaScript on your browser and then refresh this page.


Getting Started with example1



Page Contents:


 


What Is MonoGame

MonoGame is a robust cross-platform game development framework that is based on Microsoft's powerful XNA framework. The games you build with MonoGame are capable of running on iOS, Android, Mac OS X, tvOS, Windows, Linux, PlayStation 4, and Xbox.

Unlike XNA which only uses DirectX, MonoGame gives you the option to base your development around DirectX or OpenGL, so that you can best suit your programs for your targeted platform.

Because MonoGame is a framework, you use MonoGame to create your own game components and objects, which gives you much more control over your own games and allows you to create both 2D and 3D games.

But you are not limited to just developing games with MonoGame, you can also use it to create Engineering and Scientific software as well (i.e. CAD, CAM, FEA, and other Modeling Editors and Simulators).

And best of all, the MonoGame framework is Free, you don't even need to sign up or register for anything to use it, and you can use it to develop both personal and commercial software, royalty free.


 


How To Install MonoGame

Before you download and install the MonoGame framework, you should already have installed and be familiar with Microsoft's Visual Studio 2019 (Community edition or higher).

Click Here to navigate to Monogame website and download their latest development build of the MonoGame extension for Visual Studio 2019, which at the time of this writing is version 3.8.

Alternatively, you can also find the latest release on NuGet.

After you have installed the extension, I highly recommend that you install the MGCB Editor, which is a tool for editing the .mgcb files (i.e. the folders and files that will be in the games Content). This tool will make editing the .mgcb files so much easier. To register the MGCB Editor tool with Windows and Visual Studio 2019, run both of the following lines from the Command Prompt:

 
dotnet tool install --global dotnet-mgcb-editor
mgcb-editor --register

You can also install all of the MonoGame project templates for .NET CLI or Rider IDE (for Visual Studio 2019), by running the following from the Command Prompt:

 
dotnet new --install MonoGame.Templates.CSharp

 


Creating MonoGame Project With Visual Studio 2019

After you have installed MonoGame framework and its templates, you can perform the following steps to build an empty starter game project with MonoGame using Windows and Visual Studio 2019.

  1. Start Visual Studio 2019 and select Create a new project.
    example15

  2. In the Create a new project window, select C# > All platforms > MonoGame for the category filters, and then select MonoGame Cross-Platform Desktop Application, and then click the Next button to continue to the next screen.
    example16

  3. Enter the desired Project Name, Location, and Solution Name, and then click the Create button to continue.
    example17

  4. After the wizard completes creating you your new project, you should now see the source code in the Visual Studio 2019 editor.
    example18

  5. To run your game and test that it initially created everything Ok, either press the Run button in the toolbar, or press F5 function key, which should compile and execute the program.
    example19

  6. You should now see your default game window running, which at this point is just a blank blue window.
    example20

Now you too can bring your imagination to life, and enjoy creating by programming with MonoGame.


 


Upgrading To Visual Studio 2022

In this section I will go over how to convert your existing Visual Studio 2019 MonoGame project Templates into Visual Studio 2022 MonoGame project Templates, and will walk you though the steps for converting and creating a C# UWP MonoGame application project template.

I am sure there are several different other ways that I could have accomplished the below, but I found that this approach worked well for me (easy and simple to do) and therefore I simply wanted to share it with you so that you too might continue to enjoy developing with MonoGame using the latest greatest Visual Studio 2022.

Note: If you prefer to not perform the steps outlined below then I encourage you to just keep checking back with MonoGame.net and see if they have any Ready To Install templates for Visual Studio 2022 available yet. At the time of this writing they did not yet have any available, which is why I had to do the following.


Before You Begin

Before you begin, you should have the following items already downloaded, installed, and tested.


Steps To Convert And Create A MonoGame Template

The following are the steps that I took to ultimately allow myself to be able to create new MonoGame projects within Visual Studio 2022 from its Create A New Project wizard. I'm sure there might be better ways of doing this, but this is the way that I found works well enough for me.

I only needed to perform these steps ONCE:

  1. Launch Visual Studio 2019 and create a new MonoGame Win10 UWP project using one of the existing MonoGame Templates (which were installed when I downloaded and installed MonoGame 3.8 for Visual Studio 2019).
    example14

  2. Once the wizard completes creating and opening the new project, without making any changes to its source code, select Debug > X64 > Local Machine and then launch the Debugger to have Visual Studio 2019 compile and run the program, mainly to just verify that it runs and works OK as is. The program compiled and the standard CornflowerBlue screen appeared, which shows that everything ran good and with no errors.
    example3

  3. Then stop and exit the execution, and then close the solution and exit Visual Studio 2019. We no longer need Visual Studio 2019 for any of the proceeding steps.

  4. Once everything is closed, then navigate to the directory folder where the above created MonoGame solution project was saved to, and then right mouse click onto the solution file and open it with Visual Studio 2022 Community.
    example9

  5. With the MonoGame solution project now loaded in Visual Studio 2022, right click on the project name and select Properties from the popup context menu.
    example7

  6. In the Project Properties window, set the Target Version to be the highest offered (Windows 11 for me), and the Minimum Version to be the highest that the computer is capable of running (Windows 10, version 1803 for me).
    example8

  7. I then selected Debug > X64 > Local Machine then launched the Debugger to have Visual Studio 2022 compile and run the program, again mainly to just verify that it runs and works OK as is from Visual Studio 2022. The program compiled and the standard CornflowerBlue screen appeared, which shows me that everything ran good and with no errors.
    example3

  8. I then stopped and exited the execution, but left the new MonoGame solution project open in Visual Studio 2022.

  9. From the Menu Bar, I selected Project > Export Template... which launched the Export Template wizard window.
    example10

  10. I left the Project Template option selected and clicked Next
    example11

  11. On the following screen I then changed the Template Name to MonogameUWP (which is something meaningful and recognizable).

  12. I then changed the Template Description to C#, Windows, Desktop, UWP, MonoGame.

  13. For the Icon Image I browsed to the MonoGame sub-folder in Project(x86) folder and selected MonoGame.ico icon file.

  14. Afterwards I clicked Finish to complete and close the wizard.
    example12

  15. I then closed the currently opened MonoGame solution, and exited Visual Studio 2022.

Using in Visual Studio 2022

From now on, whenever I want to create a new MonoGame project in Visual Studio 2022, the template is now there and I just need to select it in Visual Studio's Create A New Project wizard window.

example13


Final Thoughts

The above process might also work Ok for converting and creating other types of MonoGame project templates (other than UWP), but I have not yet tried it, mainly because of a lack of need for me. I assume you would just select and create a different MonoGame project type within Visual Studio 2019 during Step 1, and then follow the rest of the steps the same to create the new template for that project type into Visual Studio 2022.

Thank you for reading, I hope you found this blog post educational and helpful.


orangeStarorangeStarorangeStarorangeStarorangeStar  Overall rating of 5 from 3 members

User Comments






TJDivisions© 2022