Loading assets in Monogame

Posted by Matebu on Game Development See other posts from Game Development or by Matebu
Published on 2013-11-10T17:24:23Z Indexed on 2013/11/10 22:25 UTC
Read the original article Hit count: 192

I'm creating a MonoGame application on Visual Studio 2012, yet when trying to load a texture I get the following problem:

Could not load Menu/btnPlay asset!

I have set content directory: Content.RootDirectory = "Assets"; Also the file btnPlay.png has properties set: Build Action: Content and Copy to Output directory: Copy if newer.

My constructor and LoadContent functions are totally empty, but have a look yourself:

public WizardGame()
    {
        Window.Title = "Just another Wizard game";

        _graphics = new GraphicsDeviceManager(this);

        Content.RootDirectory = "Assets";
    }

    protected override void LoadContent()
    {
        // Create a new SpriteBatch, which can be used to draw textures.
        _spriteBatch = new SpriteBatch(GraphicsDevice);

        Texture2D texture = Content.Load<Texture2D>("Menu/btnPlay");

        _graphics.IsFullScreen = true;
        _graphics.ApplyChanges();
    }

How do I properly load a texture?

© Game Development or respective owner

Related posts about XNA

Related posts about monogame