XNA系列(1)

来源:互联网 发布:js string常用方法 编辑:程序博客网 时间:2024/04/27 01:09
本系列的文章都是从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