1

I am new here,and I'm having problems with my project.
My project is a c# console game,mixed with xna game.
My problem with my project,is that I added a contents folder to it to load the xna sprites and etc,but everytime I make it run,it show,file not found on the texture loading.
I tried to see if the problem is the path,but isn't.It seens to not be recognizing the contents folder,or in other words,it threats as it does not exists,on my thoughts.
I tried to search on google,but it kept giving me weird results,
and I searched on this site for the solution,and none of them is what I wan't.
How can I make it recognize my contents folder,to be able to load sprites and other things on it?

public class Game : Microsoft.Xna.Framework.Game
{
    public GraphicsDeviceManager graphics;
    public SpriteBatch spriteBatch;

    public Game()
    {
        graphics = new GraphicsDeviceManager(this);
        graphics.PreferredBackBufferWidth = 640;
        graphics.PreferredBackBufferHeight = 480;
        graphics.IsFullScreen = false;
        Content.RootDirectory = "Content"; 
    }

    protected override void Initialize()
    {
        base.Initialize();
    }

    protected override void LoadContent()
    {
        spriteBatch = new SpriteBatch(GraphicsDevice);
        Program.TestPlayer = Content.Load<Texture2D>("characters/blue"); //Here is where gives the error
        Program.Tiles = Content.Load<Texture2D>("tiles"); //this gives error if the above script is commented.
    }

    protected override void UnloadContent()
    {

    }

    protected override void Update(GameTime gameTime)
    {
        switch (Procedures.gmode)
        {
            case GameMode.ExplorationMode:
                Exploration.ExplorationMode();
                break;

            default:
                this.EndRun();
                return;
        }
        base.Update(gameTime);
    }

    protected override void Draw(GameTime gameTime)
    {
        GraphicsDevice.Clear(Color.White);
        spriteBatch.Begin();
        switch (Procedures.gmode)
        {
            case GameMode.ExplorationMode:
                Exploration.DrawMap();
                Procedures.player.DrawTamer(spriteBatch);
                break;
        }
        spriteBatch.End();
        base.Draw(gameTime);
    }
}
Lain
  • 2,166
  • 4
  • 23
  • 47
Nakano15
  • 35
  • 9
  • 2
    Welcome to the site! This question doesn't give us much to go on other than your descriptions of the problem. Are there relevant sections of hte code you can share, along with specific error messages occurring at those points in the code? Those details go a long way toward being asble to actually help, other than just providing guesses. If you can edit your question to give more detail, we might be able to provide help. – David Jan 03 '13 at 17:45
  • I wan't to make my c# console project,recognizes the content folder i have on my project,so i will be able to load contents on my game. But it not works only by Content.RootDirectory,cause it gives the error of file not found. – Nakano15 Jan 03 '13 at 18:02
  • Also,the erro that shows is "Error loading "firsttexturetoloadname". File not found." – Nakano15 Jan 03 '13 at 18:04
  • Please post the code where you are trying to load the texture so we can see what you're doing wrong. Your description is too vague. – profexorgeek Jan 03 '13 at 18:06
  • have a look at this http://social.msdn.microsoft.com/Forums/fi-FI/csharpgeneral/thread/7d44ebe3-e9e6-4189-8d25-1458c156e7d7 – ajay_whiz Jan 03 '13 at 18:23
  • Same error...File not found... – Nakano15 Jan 03 '13 at 18:29
  • Did you see http://stackoverflow.com/questions/4644325/xna-file-not-found-problem? – PhoenixReborn Jan 03 '13 at 19:21
  • Ya,and... the files formats are in .bmp for the character sprites,and .png for the tiles. The textures paths are written on the correct path,as is written on the script. Since i'm making the xna game on a c# console,there's no "Add Content Reference". – Nakano15 Jan 03 '13 at 19:52
  • I found something that may help me with what i wan't. http://stackoverflow.com/questions/4814257/how-can-i-use-content-manager-in-console-aplication-to-load-a-new-model – Nakano15 Jan 05 '13 at 22:01

2 Answers2

1

I had to do something different to fix this,beside being...not recommended and a bit annoying.
I had to create another project,on xna,and make it pass the contents files to the xna files,then move the content folder to my project folder.
Beside being annoying to do it,it at least is working.

Nakano15
  • 35
  • 9
0

It sounds like the problem is that some settings ain't right.

Make sure that the Content project is refered to in the "Content References" in your main project.

And also make sure that the "Content Root Directory" in the content project is set to "Content" (or the same as your "Content.RootDirectory = 'Content';" is set to).

And by "My problem with my project,is that i added a contents folder" it sounds like you added a normal folder to the xna project, but you need to use a Content project, so that your resources will be compiled and refered to.


Edit

Based on your image it seems like you don't have an xna game project, but an normal project. Try to make a xna project and place your game files there instead, and then reference to your content project from the xna game project (on making a xna game project you will automatically get a new content project wich is refrenced to in the xna game project, so you can use that instead of your old one, so you don't have to mess with settings, just move your files).

ZombieSpy
  • 1,376
  • 12
  • 23
  • I already said that there's no "Content References" area on my project. And i set the Content.RootDirectory as "Content",as the folder name is. And yes,i'm using a Content project on my game,if you wanna,i may send a photo of it. – Nakano15 Jan 04 '13 at 23:43