XNA Creators Club Online
Page 1 of 1 (3 items)
Sort Posts: Previous Next

I have a problem with Loading Assets

Last post 20/12/2008 18:16 by Invisi. 2 replies.
  • 20/12/2008 15:03

    I have a problem with Loading Assets

    I've just started using XNA Studio Express and Programming in C# so my knowledge is kinda minimal. So I've started with the tutorials 2D Cannon game that MS provide, but I'm stack on loading a background
    because although it compiles perfectly when I run it, it says that it can't find the file. But i followed everything to the letter
            protected override void LoadContent()
            {
                spriteBatch = new SpriteBatch(graphics.GraphicsDevice);

                backgroundTexture =
                    Content.Load<Texture2D>("Sprites\\background");   <--------Here

                //Create a Rectangle that represents the full
                //drawable area of the game screen.
                viewportRect = new Rectangle(0, 0,
                    graphics.GraphicsDevice.Viewport.Width,
                    graphics.GraphicsDevice.Viewport.Height);

                base.LoadContent();
            }

    Could someone help me pls : )
  • 20/12/2008 15:42 In reply to

    Re: I have a problem with Loading Assets

    In your project there is a Content folder/section. Ensure your background texture is placed in a folder called Sprites (under the Content folder).

    If you are using Xna 3.0 then the properties of the background file should be: (Xna 2.0 is slightly different e.g. BuildAction might be Content instead of Compile).

    Asset Name: background
    BuildAction: Compile
    Importer: Texture - XNA Framework
    Processor: Texture - XNA Framework

    when you build (or rebuild) check the build output window to see something like:

    Building Sprites\background.jpg -> C:\...\Bin\Content\Sprites\background.xnb

    then when the build is done, check the Content\Sprites folder in your bin folder for a file called background.xnb



    Game hobbyist hell-bent on coding a diabolical Matrix
  • 20/12/2008 18:16 In reply to

    Re: I have a problem with Loading Assets

    Thank you for your help, I got it to work : )
Page 1 of 1 (3 items) Previous Next