【发布时间】:2015-08-11 05:11:31
【问题描述】:
我正在使用 C# 和 XNA 4.0 制作游戏,我想使用纹理向玩家显示关卡选择菜单中每个关卡的屏幕截图。 因为我只使用一种纹理,所以每次播放器在菜单上突出显示一个新选项时,我都需要加载一个新纹理。我这样做的代码类似于以下:
Texture2D levelTexture;
if(user.HighlightsNewOption)
{
//Notice that there is no form of unloading in this if statement
string file = levelSelectMenu.OptionNumber.ToString();
levelTexture = Content.Load<Texture2D>(file);
}
但是,我担心当前的设置会导致内存使用问题。这个问题会通过先卸载纹理然后加载新纹理来解决吗?如果是这样,我该怎么做?
【问题讨论】: