I am coming straight from XNA and I installed the latest version of MonoGame today (2015-12-22) for Visual Studio 2015 Community. I created a project from the windows Project template.
I right click the content folder and add a png-file. I compile without error but it stops during runtime because it can't find the content file. My solution look like this
Game1.cs look like this:
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
namespace homer
{
public class Game1 : Game
{
GraphicsDeviceManager graphics;
SpriteBatch spriteBatch;
private Texture2D simpson;
public Game1()
{
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
}
protected override void Initialize()
{
base.Initialize();
}
protected override void LoadContent()
{
spriteBatch = new SpriteBatch(GraphicsDevice);
simpson = Content.Load<Texture2D>(@"Images/Homer");
}
protected override void UnloadContent(){ }
protected override void Update(GameTime gameTime)
{
if (Keyboard.GetState().IsKeyDown(Keys.Escape))
Exit();
base.Update(gameTime);
}
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.CornflowerBlue);
spriteBatch.Begin(SpriteSortMode.FrontToBack, BlendState.AlphaBlend);
spriteBatch.Draw(simpson, new Vector2(200, 100), Color.White);
spriteBatch.End();
base.Draw(gameTime);
}
}
}
The problem I encounter is that MonoGame do not make xnb-files from the png and put it in my output folder. I tried to copy the file manually from a compiled XNA project to my MonoGame debug folder and it worked. I have done nothing but create a project from the template and trying to load an image. What do I need to do to make MonoGame compile xnb-files for me. It also runs if I change "Do not copy" to "Copy always" but that is not optimal for runtime as I understand it. Also, I don't want it to be too easy for the users to doodle in the graphics.
Content.mgcb look like this
#----------------------------- Global Properties ----------------------------#
/outputDir:bin/Windows
/intermediateDir:obj/Windows
/platform:Windows
/config:
/profile:Reach
/compress:False
#-------------------------------- References --------------------------------#
#---------------------------------- Content ---------------------------------#