Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I've read forum threads and questions and I done just about everything. I need to know what am I screwing up here.

Here's the code in the constructor.

Content.RootDirectory = "GameStateContent";
//Content.RootDirectory = "Content";

And this is in the LoadContent method

 menu = this.Content.Load<Texture2D>("mainmenu");

And here's the image screen shot of the folder structure. http://i.stack.imgur.com/HnndE.png

Any helps on this?

Thanks.

share|improve this question

2 Answers 2

up vote 10 down vote accepted

Your problem is that you are changing the root directory to the wrong thing!

Based on your screenshot, your content project is called "GameStateContent", and using the default template will be created in a directory called "GameStateContent". That is the directory to which Visual Studio will copy all the content files you drag onto that content project (if they are not there already).

But the output directory (the thing in brackets, in Solution Explorer) is still "Content". This is where the content project outputs the XNB files that it builds from your input files. So if you tell XNA that the content root directory is "GameStateContent" then it will be looking in the wrong place!

If you click the project and press F4 to bring up the properties window, you can change the root directory.

The ContentManager in XNA basically looks for XNB files in the directory you specify, next to the game executable. You can go in and look at that directory in your project output directory. It will probably be:

GameState\bin\x86\Debug\Content

Go in and have a look for it, check it has the right name and contains the right XNB files.

I don't understand why your game project has a "Content" directory (or bin and obj, for that matter). Or why there's another "Content" directory in your GameStateContent project. You can probably safely remove those.

Providing you haven't made any other strange changes, you should be able to simply set:

Content.RootDirectory = "Content";

and have it work.

share|improve this answer

Your images still need to go in the Content folder of your content project; and they have the same names as images in your GameState project, so I presume there will be a conflict there and you'll need to remove or rename one set of the images. I don't think you need to modify Content.RootDirectory, but you do need to make sure your GameState project references your GameStateContent project. Instructions here.

If I may ask, why do you need the separate content project?

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.