![](/img/trans.png)
[英]How to add XNA Content Pipeline to Silverlight 5 in Visual Studio Web 2010 Express?
[英]How do I properly reference Content in Visual Studio 2010 with XNA?
我正在使用带有Microsoft XNA的Visual C#Studio 2010 Express制作C#游戏。
目前,我正在尝试将内容加载到游戏中,但是相对的Content路径存在问题。 我当前的代码如下所示:
private Texture2D planetBackground;
private Texture2D groundFacility;
private Texture2D hoverShip;
private Texture2D attackShip;
protected override void LoadContent()
{
spriteBatch = new SpriteBatch(GraphicsDevice);
planetBackground = Content.Load<Texture2D>("spacebackground.png");
groundFacility = Content.Load<Texture2D>("planetstation.png");
hoverShip = Content.Load<Texture2D>("ship2.png");
attackShip = Content.Load<Texture2D>("ship1.png");
}
Content.RootDirectory
当前设置为“内容”。
如何构造图像的路径,以便它们加载? 目前,我得到了ContentLoadException: file not found
,因此很明显我的相对路径是错误的。 路径从哪里开始?
删除文件扩展名:
planetBackground = Content.Load<Texture2D>("spacebackground");
XNA将所有文件转换为.XNB文件,因此无需指定扩展名(除非文件名中包含多个点)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.