tags:

views:

43

answers:

1

Hello, I am currently messing with C# XNA 4.0, but I am having some problems assigning a Texture2D to an existing Texture2D. An example of the code shown below:

    protected override void LoadContent()
    {
        spriteBatch = new SpriteBatch(GraphicsDevice);

        texDisc48 = Content.Load<Texture2D>("textures/disc_24");
        texDisc48 = Content.Load<Texture2D>("textures/disc_48");
        texDisc96 = Content.Load<Texture2D>("textures/disc_96");
    } 
// Random place in the code
texCurrentDisc = texDisc96;

But when I am trying to use the texCurrentDisc in etc Draw, I get the following error: This method does not accept null for this parameter. Parameter name: texture. The texCurrentDisc is just initalized as: Texture2D texCurrentDisc;

A: 

Can you load the texture using "textures/disc_96"? I thought it had to use something like "textures\disc_96". Also you assign to texDisc48 twice. So maybe try:

    texDisc24 = Content.Load<Texture2D>("textures\\disc_24");
    texDisc48 = Content.Load<Texture2D>("textures\\disc_48");
    texDisc96 = Content.Load<Texture2D>("textures\\disc_96");
ShannonG