Will MonoGame fit my needs?

Hey Everyone,

Short background about me in preparation for the question.

  • Made games as a Level Designer in custom engines (that was built using C++) where we used Maya as a level editor and used LUA as scripting so I’m rather familiar with setting up assets via text and not how it’s in Unity.
  • Released a commercial game on multiple platforms using Unity as the only programmer (Steam, Origin, Switch, PS4)
  • Started programming in Unity in 2013.
  • Worked professionally in the industry at indie studios since end of 2014.

I want to start making my games outside of Unity, I would say that I’ve got good skills when it comes to C# and I’ve enjoyed creating my own level editors inside of Unity for some of my games.

My question is: If I want to release 2D games on Desktop, mobile and Switch. Am I able to do that in MonoGame using one project and not having one for each platform?

Also on my mind for future problems, how difficult is it to create option to rebind keyboards or controllers and are there some frameworks that helps with figuring out what type of controller is connected? Sorry if I get the lingo wrong, I’m new to programming outside of Unity and this thing was something I had huge problems with when using Unity, so I turned to a plugin from the Asset Store which handle this.

Thank you for reading!

1 Like

Hey @AnderssonKev :slight_smile:

No. MonoGame does not do runtime abstractions (i.e. if platform == Android do stuff). Instead we have different projects for each platform and users reference the project for the platform their targeting. That means you need one project for each platform.

That said, you can put most of the game code in a shared project and include that in the platform specific projects. They then only need to handle platform specific stuff, like touch vs mouse input, screen resolution, launching the game…

MonoGame doesn’t really offer anything for this out of the box, but it’s pretty easy to implement. Just make sure you handle it at the start of the project because it’s a pain to change later.

I don’t think there is anything like that. For cross platform desktop projects you can use SDL directly to get a gamepad name (MG uses SDL in the backend for input and windowing for the cross platform desktop aka DesktopGL platform). I think that’s the most relevant one. Basically for each platform you’d have to use reflection to get the platform-specific gamepad object from MonoGame and then use the platform-specific API to get the name from it.

Thanks for the replies @Jjagg

So when I start a new project, would it be okay to start either a “MonoGame Windows Project” or “MonoGame Cross Platform Desktop Project” and then take it from there? To clarify, what type of project would the “shared project” be when I start that project from the “New Project” window?

I’m actually pretty excited so I’ll start to just follow some tutorials to get more familliar with everything.

I have the same problems about the “shared project”, because I can’t find it :joy:

A shared project is nothing monogame-specific.
It’s a template in visual studio.

The way I usually setup cross-platform monogame-projects is somewhat like this:
MyGameSolution

  • MyGame (Shared Project, this is where your game1.cs will go)
  • MyGame.DesktopGL
  • MyGame.Android
  • MyGame…

The Shared Project is then referenced from the Platform-Projects.

I see, doesn’t sound terrible. I bet there are tutorials or documentation on how to set this up.

Thank you for explaining!

Well it’s really easy actually.

  1. Create a new Monogame Project.
  2. Add a Shared Project
  3. Copy Content-Folder from Monogame-Project to Shared Project
  4. Delete Content.mgcb from Monogame-Project(But not the Content Folder)
  5. Delete game1.cs from Monogame-project
  6. Add Shared Project as a reference to Monogame-Project
  7. Add Existing File to Monogame-Project Content Folder, in File Dialog choose the Content.mgcb from the Shared Project and before clicking “Add” choose the little arrow next to it and select “Add as Link”
  8. Then set the content-build-action for the linked Content.mgcb to Monogame Content Reference
2 Likes

I’m totally saving this for the future when I’m making a small experimental project!

Here’s a great video tutorial I found useful for making shared projects. It also covers the surface of handling platform-specific code.

Wow, you all are too kind! I’ve actually started watching one introduction tutorial from that guy to get started.