![](/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.