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.

  • Adding contents to a game
  • ContentManager Class
  • How do I unload content from the content manager?
  • XNA game studio LoadContent
  • 链接地址: http://www.djcxy.com/p/95524.html

    上一篇: 从System.Type变量创建类的实例

    下一篇: XNA加载/卸载逻辑(contentmanager?)