Introduction
I haven’t written anything for a while, but I spent a good while on the issue below, so I thought I’d share.
The Problem
I recently starting playing with MonoGame. I’d previously dabbled with using Javascript and HTML5; you can see the results here.
Being predominantly a C# programmer, I decided to try a similar thing using the Monogame framework. When you install Monogame, you’re faced with a box, asking you to either start a Monogame project, or a Monogame with XAML project:
So, what’s the difference?
I searched for this on-line, but found more or less nothing; consequently, I thought: what do I need XAML for if I’m writing a game?
And I was right - you don’t… that is, unless you’re using anything later than VS2010 (in which case it allows you to display text without the ridiculous palava that you HAVE to go through otherwise, just to get a FONT into your game.
Having made my decision, I went through this rigmarole, and moved onto the next part of the game: I needed to display a Microsoft Ad Control… which is a XAML control.
So, unless you KNOW that you don’t need XAML… and my guess is that you DON’T, then select XAML & Monogame. You can migrate your code across at a later time though; if you’ve structured your code properly then it may only be a 20 minute job.
Having transferred to use XAML, the question does arise as to how. It’s by no means clear, and I found no documentation at all.
Interacting With XAML / Benefits of having XAML
Annoyingly, I haven’t found any real way to interact with the game graphics from the XAML or vice-versa. It looks like you’d have to keep the instance of the main game page and talk to that from the game logic.
Without this though, you can simply overlay the game graphics on top of the XAML and that seems to work fine. In order to position my ad control I just created the following XAML:
;
;
Another benefit that I didn’t consider until I moved across is all the resume suspend logic (that is so important in Windows 8 apps).
Conclusion
That’s pretty much all I’ve got to say about this. It’s not an ideal way of doing things, but Monogame is worth using, and it’s free (at least until you want to deploy to Android or something - at which point you pay).