user2931015
user2931015

Reputation: 219

XNA game studio LoadContent

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.

Upvotes: 0

Views: 639

Answers (1)

pinckerman
pinckerman

Reputation: 4213

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");

Upvotes: 1

Related Questions