Export (0) Print
Expand All
5 out of 7 rated this helpful - Rate this topic

How To: Add a Game Asset to Your Game

This example 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 or Xbox 360 game project is loaded in XNA Game Studio.

Bb313966.note(en-US,XNAGameStudio.20).gifNote

For information on loading content at runtime, see How To: Load Content.

For information on drawing a texture as a sprite, see How To: Draw a Sprite.

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 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.

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

    Making a reference to an existing asset in your project is quite different than adding an existing item to your project. A file reference stores only the path to the asset in question, not a copy of the contents. This is useful if the referenced asset is dependent on additional external assets and ensures that the latest version is always used by the solution. This differs from adding a copy of the asset to the project. In this case, it is possible to break external dependencies and create extra work if the original content changes but the copy is not updated.

    For these reasons, it is recommended that any media used by the solution be in the nested content project of your solution and that a reference to the asset is added and not a copy.

  4. After adding the asset to the solution, open the Properties window to verify that the proper importer and processor are specified (right-click on the file in Solution Explorer and choose Properties from the context menu). 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.

  5. Save the solution.
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.