XNA系列(1)

本系列的文章都是從MSDN上找的文章,添加一點學習筆記。
 
XNA Game Studio 3.0
Adding Game Assets to Your Game

Demonstrates how to add a texture asset to your game. The same procedure can also be applied to model and sound assets. It is assumed that an existing Windows, Xbox 360, or Zune game project is loaded in XNA Game Studio.

There are two ways to add a texture asset to your game, either by adding the asset file or by adding a link to the asset.

我們想建立遊戲,首先可能會需要一些素材,這部分內容就是關於如何添加素材的.添加素材有兩種方式:

1.添加素材文件

2.添加素材鏈接

Bb313966.note(en-US,XNAGameStudio.30).gifTip

Adding an existing asset to your project is quite different from adding an existing item as a link to your project. The first method creats a copy of the asset file and adds the copy to your project. Adding an asset as a link stores only the path to the asset file.

注意:添加素材文件和添加素材鏈接是不一樣的,前者將素材內容拷貝到Project中,後者只是維護一個指向素材的路徑。

Adding the Texture Asset to the Game Project

When you add a game asset (not as a link), XNA Game Studio makes a copy of the asset file and adds the copy to the content project. For this reason, adding a game asset in this manner may be most appropriate when the asset is used by only one developer in one project and is NOT expected to be changed.

如果一個素材不需要改變而且只是針對一個開發者時,一般我們可以直接添加素材文件到Project中。

To add the texture asset to the game project

  1. From the Solution Explorer window, right-click the Content node, click Add, and then click Existing Item.

  2. Navigate to the location of the texture, and select it.

    For this example, the asset is called B1_nebula01.tga.

  3. Click the Add button.

    This creates a copy of the selected asset in your project.

  4. Save the solution.

Adding the Texture Asset as a Link to the Game Project

Adding an asset as a link is useful if the referenced asset depends on additional external assets. It ensures that the solution always uses the latest version. For this reason, adding a game asset as a link may be most appropriate when the asset is shared with other people or other game projects, or is likely to be changed.

To add the texture asset as a link to the game project

  1. From the Solution Explorer window, right-click the Content node, click Add, and then click Existing Item.

  2. Navigate to the location of the texture, and select it.

    For this example, the asset is called B1_nebula01.tga.

  3. Click the small arrow to the right of the Add button, and then click Add as Link.

    This creates a reference to the selected asset (and not a copy) in your project.

  4. Save the solution.

添加文件和文件鏈接的不同就在Add button的行爲選擇。

Verifying the Content Importer

You should use this procedure each time you add a game asset. This ensures that the asset will be correctly recognized and processed by the Content Pipeline.

每次添加素材都要確認一下Content Pipeline,就是說需要確認該素材可以被XNA正確有效的加載。

To verify the game asset will use the correct content importer

  1. After you add the asset to the solution, open the Properties window to verify that you specified the correct importer and processor.

  2. To verify, right-click on the file in Solution Explorer, and then, from the context menu, click Properties.

    For this example, the Content Importer is Texture - XNA Framework and the Content Processor is Texture - XNA Framework.

    For more information on the Properties window of a game asset, see Game Asset Properties.

  3. Save the solution.

主要檢查:Content Importer和Content Processor

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章