0

I found a code to load multiple objects in XNA game stuido but can't call load contect method, what do I need to do? Do I need to call it another class besides Game1 or calling in game1 is just fine?

public override void LoadContent()
{
    // Create a new SpriteBatch, which can be used to draw textures.
    spriteBatch = new SpriteBatch(GraphicsDevice);

    //Dictionary<string, Model> models = new Dictionary<string, Model>;

    mymodel = Content.Load<Model>("Models\\tableBasse2");

    aspectRatio = graphics.GraphicsDevice.Viewport.AspectRatio;

    backgroundTexture = Content.Load<Texture2D>("123");
    screenWidth = this.Window.ClientBounds.Width;
    screenHeight = this.Window.ClientBounds.Height;
}

//__http://stackoverflow.com/questions/4052532/xna-get-an-array-list-of-resources
public static Dictionary<string,Model> LoadContent

This load content not called in this line. I write this generally to show I call this LoadContent.

pinckerman
  • 4,115
  • 6
  • 33
  • 42
user2931015
  • 219
  • 2
  • 8
  • 21
  • you need to be a little more specific about what you need to do... can you elaborate what are you trying to do? – lauCosma Nov 20 '13 at 05:55
  • If, for some reason, you need it to be in a separate method, name it for example 'CustomLoadContent()' and call it from the 'Game1.LoadContent()' method. All content should be loaded there except when you want lazy loading and really know what you are doing. – Andrei V Nov 20 '13 at 05:59

1 Answers1

1

To use Content you need to be in a class that inherits from GameComponent or DrawableGameComponent, because only Game class has it.

And then you can call it as:

Game.Content.Load<..>("path");
pinckerman
  • 4,115
  • 6
  • 33
  • 42