I am having a problem in my game where I cant figure out how to load content after the game has started. I have a basic RenderObject set up that has a Texture2D, location, etc, and a function that loads stuff
public void LoadContent(ContentManager content)
{
image = content.Load<Texture2D>(graphic);
}
image is the texture2D, every renderObject has this function and it’s called during the game start.
protected override void LoadContent()
{
// Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch(GraphicsDevice);
for (int i = 0; i < RenderObject.renderObjects.Count; i++)
{
RenderObject.renderObjects[i].LoadContent(this.Content);
}
}
This only loads content for the initially existing objects, and if I create any other objects it crashes because they want to pull non-existent content. Should I be doing this a certain way so I don’t have to have one huge LoadContent where I have to manually load every single graphic at the start of the game?