我对 XNA 框架很陌生。我正在 XNA 中为 windows phone 7 编写示例应用程序。
目前我面临一个问题。
在示例中,我正在加载一个 Texture2D 并将其放置在下一行并将其分配给 null。我再次将相同的图像加载到相同的成员变量。但在平局中,我得到了 ObjectDisposedException。
如果我删除 dispose 调用,它不会给出任何异常。
请帮我解决这个问题。
样本:
Texture2D texture = null;
protected override void LoadContent()
{
texture = Content.Load<Texture2D>("Back");
texture .Dispose();
texture = null;
texture = Content.Load<Texture2D>("Back");
}
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.CornflowerBlue);
spriteBatch.Begin();
spriteBatch.Draw(texture , new Vector2(0, 0), Color.White);
spriteBatch.End();
base.Draw(gameTime);
}