Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm researching Monogame. Their goal is to allow "easy" porting of an existing XNA/Windows game to mobile.

Does this mean you can have one solution (theoretically) with shared code, and it works on all three platforms (PC, Android, iPhone)? Or do you need to port your game from PC to Android, and then again to iPhone?

I'm sure "write once, run anywhere" works 80% of the time, I'm not worried about that other 20% like support for GPS, acceleratometer, etc. which doesn't exist on all platforms.

share|improve this question
1  
Not a real answer and I've never tried MonoGame, but take a look at the Delta Engine. –  mc-kay May 30 '12 at 7:35
    
Whoa @mc-kay. What's your affiliation to them? –  ashes999 Aug 16 '12 at 18:11

1 Answer 1

up vote 2 down vote accepted

You can keep all your code in one solution and most of the code will only have to be written once and work on all platforms.

Here's the catch, you need to create a new project per platform. For example you might have YourGame.Core, YourGame.Android and YourGame.Windows. Code that is shared between projects can live in the Core project and be added to the platform specific projects as linked files. It's a bit a maintenance pain, but not as much as you might think. Many developers have reported that they setup a project for a new platform in around 15 minutes once they have the windows one working.

The reason for this pain stems back to the ability to have a single project targeting multiple frameworks. For example, you can create a project that targets Mono / .NET 4 and a different project that targets Android 2.2. Each project can contain identical code, but there's currently no way to target both frameworks at the same time within the same project.

This problem is not isolated to Mono and has also been reported when people are developing for Microsoft specific platforms like Windows Phone and Silverlight.

http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/2051965-allow-a-project-to-target-multiple-frameworks-ful

There is a better solution in the works called Portable Class Libraries. The idea is that you can have all of your core code in a single project and simply reference the DLL in each of your other projects.

http://msdn.microsoft.com/en-us/library/gg597391.aspx

It looks like Mono has at least partial support for Portable Class Libraries according to the Mono 3.0 release notes, but I haven't tried it yet.

http://www.mono-project.com/Release_Notes_Mono_3.0#Smaller_Updates

share|improve this answer
1  
It's not that bad - you just basically put a few lines in each and call a few init functions. The rest, if done with careful defines in your code, like IF #MOBILE; will make porting realtively painless. –  Vaughan Hilts Nov 7 '12 at 7:08
    
Exactly what I did. +1/Accepted –  ashes999 Feb 5 '13 at 4:25

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.