Adding Content to the Game

Topics: Windows Phone
Nov 18, 2012 at 11:45 PM
Edited Nov 18, 2012 at 11:46 PM

Hi, I'm new to MonoGame but have a long history in XNA. Since Windows Phone 8 support for XNA is gimped by backwards compatibility (I want full 720p!), I've decided to go ahead and jump to MonoGame. After reading through the threads here I've managed to set up a MonoGame Windows Phone 8 project. Now I've started writing my game code, but quickly realized that I don't know how to add content to the game. Do I need to add a traditional XNA emtpy Content Project? If so, I see no way to have it referenced by my game project. Or does Mono have its own Content Pipeline (the directories in the Git repo seemed to hint at this)? Or, do I need to edit the .csproj manually?

Nov 19, 2012 at 1:06 AM
Edited Nov 19, 2012 at 1:06 AM

You can use the Content Pipeline of your current project:

- create a folder Content in VS 2012

- copy your XNBs over to this folder

- set the 'Build Action' property in VS2012 for the XNBs to 'Content'

- set the 'Copy to Output' property to 'Copy if newer'


If you have many XNBs it's easier to edit the vsproj file.


<Content Include="Content\**\*.*">     <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>


That is setting the properties to all the XNBs automatically.


If you change any content files you can do so in your old project and copy the files over. 

Nov 19, 2012 at 1:29 AM
Edited Nov 19, 2012 at 1:31 AM

Thanks, though I don't have an XNA project at all for this game, I'm starting scratch in Mono. Still, I think I understand what you're getting at. I've added a dummy XNA game and contentproject to the solution, I'll just build the content .xnbs from there and copy them into the main game project's Content folder. I've placed that node snippet in the first <ItemGroup> node with the <Compile> nodes in my .csproj, I take it that is correct? It hasn't yelled at me.

Thanks for the help, I'm excited about trying MonoGame and developing for Windows Phone 8 in C#.

Nov 19, 2012 at 9:43 AM

>I've placed that node snippet in the first <ItemGroup> node with the <Compile> nodes in my .csproj, I take it that is correct? 

If it works, yes :-)

A best practice at initial project setup seems to be:

- add one xnb file

- change the settings in VS2012 ('Build Action' and 'Copy to Output') for this xnb file, see above

- save the project and open the .vsproj in an editor

- then search for the 'Content' node and change the lines like shown above