XNA Load/Unload logic (contentmanager?)
I am trying to make a point-and-click adventure game with XNA, starting off simple. My experience with XNA is about a month old now, know how the classes and inheritance works (basic stuff).
I have a problem where I cannot understand how I should load and unload the textures and game objects in the game, when the player transitions to another level. I've googled this >10 times, but all I find is hard coding while I only understand the basics of unloading yet.
All I want, is transitioning to another level (replacing all the sprites with new ones).
Thanks in advance
Content Load:
SpriteBatch spriteBatch;
// This is a texture we can render.
Texture2D myTexture;
protected override void LoadContent()
{
// Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch(GraphicsDevice);
myTexture = Content.Load<Texture2D>("mytexture");
}
Content Unload:
protected override void UnloadContent()
{
Content.Unload();
}
These are the simplest methods of loading and unloading contents. For more information refer to the following link.
上一篇: 从System.Type变量创建类的实例