这样添加资源有什么问题?

zhanchili 2008-07-11 10:53:07
//App.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="MediaPath" value="..\..\..\Media\Blockers\" />
</appSettings>
</configuration>

//主程序
namespace myBlockers
{
public class GameEngine : IFrameworkCallback,IDeviceCreation
{
//....
public static readonly string MediaPath = ConfigurationManager.AppSettings.Get("MediaPath");

//The information for the mesh that will display the level
private Mesh levelMesh = null;
private Texture[] levelTextures = null;
private void OnCreateDevice(object sender, DeviceEventArgs e)
{
SurfaceDescription desc = e.BackBufferDescription;
// Create the mesh for the level
ExtendedMaterial[] mtrls;
levelMesh = Mesh.FromFile(MediaPath + "level.x", MeshFlags.Managed, e.Device, out mtrls);

// Store the materials for later use, and create the textures
if ((mtrls != null) && (mtrls.Length > 0))
{
levelTextures = new Texture[mtrls.Length];
for (int i = 0; i < mtrls.Length; i++)
{
// Create the texture
levelTextures[i] = TextureLoader.FromFile(sampleFramework.Device, MediaPath +
mtrls[i].TextureFilename);
}
}


}
private void OnDestroyDevice(object sender, EventArgs e)
{
// Clean up the textures used for the mesh level
if ((levelTextures != null) && (levelTextures.Length > 0))
{
for (int i = 0; i < levelTextures.Length; i++)
{
levelTextures[i].Dispose();
}
// Clean up the mesh level itself
levelMesh.Dispose();
}

}
//...
}
}
...全文
79 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhanchili 2008-07-12
  • 打赏
  • 举报
回复
顶.
zhanchili 2008-07-12
  • 打赏
  • 举报
回复
关于Manage DirectX的东西知道的人很少吗?
beancurd005 2008-07-12
  • 打赏
  • 举报
回复
// Clean up the mesh level itself
levelMesh.Dispose();


应该是这个地方的问题吧,你的业务逻辑我不太清楚,但希望能对你有点帮助哦!
zhanchili 2008-07-12
  • 打赏
  • 举报
回复
哇,为什么没回答.
zhanchili 2008-07-11
  • 打赏
  • 举报
回复
Build能成功,但Debug就抛异常.指向下面的代码.
//dxmut.cs
System.Diagnostics.Debug.Assert(State.Device.Disposed, "Device should be disposed here.");

111,045

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧