Reputation: 1
So basically I am making a small test game and I have a class that is used in the creation of all the entities in the game so I pass the class on to the object Player and run this code:
protected override void LoadContent()
{
spriteBatch = new SpriteBatch(GraphicsDevice);
font = Content.Load<SpriteFont>("LCD");
Player.Sprite = Content.Load<Texture2D>("Sprites/Player");
}
But for some reason, every time I attempt to debug and run it, it gives me an error which is weird because before the error did not show and it would run fine, here is what the error says:
ContentLoadException was unhandled
Could not load Sprites/Player asset as a non-content file!
I have a folder within the content folder named "Sprites" which does exactly as its names suggests, holds my sprites, and all the spelling is done correctly. I cannot figure out why this problem persist though.
Upvotes: 0
Views: 1114
Reputation: 1
I Figured out the problem, you see I did not make the resource "Copy" at all and it needs to copy once to get it into the MonoGame project folder, Rookie mistake I know but at least this will help others who get stuck like me, Thank you everyone who attempted to help with this issues, I appreciate your time.
Upvotes: 0
Reputation: 3185
It would be beneficial for me to know how you added the asset, where and which properties does it have configured, as well as the project structure to fully understand the root of the problem.
In any case, I have a blog post that may be useful for solving this problem, it was written using Monogame 3.2, if I remember correctly and explains how to create a really simple 2D game using XNA and Monogame.
From the series, what may be relevant in your case is the following block, explaining how to add an image asset to your game project. Keep in mind that the path to your sprite image will be different than the one in my example as you have the "Sprites" subfolder.
You need to right click on the
Content
folder in the solution explorer, choose theAdd Existing Item
option and then select the image.Given that
Monogame
works in a different way thanXNA
when managing the content pipeline, you are going to have to change the properties of the image in order for the framework to recognize it. To do this, select the image and navigate to it’s properties (F4 in Visual Studio, or right click -> properties).Change it so that the image gets copied to the output folder if it is newer.
You can find the full blog entry here.
Upvotes: 1
Reputation: 245
Check your string for errors. If I'm correct I saw this error a lot when I capitalized something that shouldn't have been.
String: "Sprites/Player"
Upvotes: 0