Export (0) Print
Expand All

Creating a Windows Game or Library Project

Describes how XNA Game Studio includes a set of project templates that will help you to develop Windows-based projects using the XNA Framework.

Starting a New Project

To start a new project

  • To begin a new Windows-based project, click File, and then click New Project.

    A dialog box appears and lists a number of project templates.

Bb203928.UsingXNA_NewProjectDialog40(en-us,XNAGameStudio.40).png

XNA Game Studio provides template types for XNA Framework game development in the XNA Game Studio 4.0 section of the Visual C# project types. The templates offered for developing XNA Framework games for Windows are:

  • Windows Game (4.0)–A project for creating an XNA Framework 4.0 game application for Windows.
  • Windows Game Library (4.0)–A project for creating an XNA Framework 4.0 game library for Windows.
  • Content Pipeline Extension Library (4.0)–A project for creating an XNA Framework 4.0 Content Pipeline Extension Library.

Windows Game (4.0)

XNA Game Studio provides a Windows Game (4.0) template that creates and loads a set of starter files. This new project contains basic code that implements a simple, framed window with a colored background.

To create a Windows Game (4.0) project

  1. On the File menu, click New Project.

  2. Select the Windows Game (4.0) project type.

  3. Type the name for the game project in the Name box.

    You can also modify the default values for the Location and Solution Name controls.

  4. Click OK to create and load the new project.

Results

The new starter project contains the following important features.

Bb203928.UsingXNA_SolutionExplorer_Windows_Game(en-us,XNAGameStudio.40).png

Project Properties

These properties control many aspects of your current project. Some examples include general application settings, debug settings, and additional project resources. You can use the Project Designer to modify the values for these properties.

In addition to these properties, assembly information (such as the game title) is stored in the AssemblyInfo.cs file. You can use the Assembly Information dialog box to modify this information, or you can manually edit the .cs file.

References

References to the following assemblies are added automatically to a new game project.

  • Microsoft.Xna.Framework
  • Microsoft.Xna.Framework.Avatar
  • Microsoft.Xna.Framework.Game
  • Microsoft.Xna.Framework.GamerServices
  • Microsoft.Xna.Framework.Graphics
  • Microsoft.Xna.Framework.Net
  • Microsoft.Xna.Framework.Storage
  • Microsoft.Xna.Framework.Video
  • Microsoft.Xna.Framework.Xact
  • mscorlib
  • System
  • System.Core
  • System.Xml
  • System.Xml.Linq

In addition to these standard assemblies, you can add assemblies as needed for your project.

Content References

The content references node specifies the content projects whose assets will be used by the game on this platform. For more information, see Game Content Project.

Game.ico File

A 32 × 32 default icon representing your game.

Game1.cs File

This file is a good starting point for adding simple game logic and basic features. It implements a single class (derived from Game and called Game1), and it overrides five methods: LoadContent, UnloadContent, Initialize, Draw, and Update. In addition, the Game1 constructor is defined. Use these methods to initialize your game components, to load and render your game content, and to handle any input from the user or changes to the game environment.

GameThumbnail.png

The icon appears in the Games Library, and when a game is packed for distribution as a .ccgame.

For more information about distribution, see Sharing Your Game Package.

Program.cs File

This file also implements a single class (called Program) that provides an entry point to game execution. Usually, little code is added to this file unless the game is fairly advanced.

Content Project

The content project occupies a parallel position with the game project in the solution, and it stores and builds art assets for the game. For more information, see Game Content Project.

Windows Game Library (4.0)

XNA Game Studio provides a Windows Game Library (4.0) template that creates and loads a set of starter files. Typically, projects of this type contain managed classes that implement basic or advanced features used by a game engine or 3D renderer. Once completed, these class libraries can be referenced by other Windows projects. They provide common functionality without having that code reside within the game project.

The new project contains basic code that implements an empty library, usable by other Windows Game projects or Windows Game libraries.

Results

The new starter project contains the following important features.

Bb203928.UsingXNA_SolutionExplorer_Windows_Library(en-us,XNAGameStudio.40).png

Project Properties

These properties control many aspects of your current project. Some examples include general application settings, debug settings, and additional project resources. You can use the Project Designer to modify the values for these properties.

In addition to these properties, assembly information (such as the library title) is stored in the AssemblyInfo.cs file. This information can be modified using the Assembly Information dialog box or by manually editing the .cs file.

References

References to the following assemblies are added automatically to a new Windows Game Library project:

  • Microsoft.Xna.Framework
  • Microsoft.Xna.Framework.Avatar
  • Microsoft.Xna.Framework.Game
  • Microsoft.Xna.Framework.GamerServices
  • Microsoft.Xna.Framework.Graphics
  • Microsoft.Xna.Framework.Net
  • Microsoft.Xna.Framework.Storage
  • Microsoft.Xna.Framework.Video
  • Microsoft.Xna.Framework.Xact
  • mscorlib
  • System
  • System.Core
  • System.Xml
  • System.Xml.Linq

In addition to these standard assemblies, you can add other assemblies as needed for your project.

Content

The nested content project stores and builds content that is to be included in the game library. This is useful for including reusable content assets that support the classes and methods in the game library. For more information, see Game Content Project.

Class1.cs File

This file implements an empty C# class within a namespace. This provides a starting point for the class library.

To create a Windows Game Library (4.0) project

  1. On the File menu, click New Project.

  2. Select the Windows Game Library (4.0) project type.

  3. Type the name for the library project in the Name box.

    You can also modify the default values for the Location and Solution Name controls.

  4. Click OK to create and load the new project.

Content Pipeline Extension Library (4.0)

XNA Game Studio provides a Content Pipeline Extension Library (4.0) template that creates and loads a set of starter files. The template provides a starting point for developers wishing to create their own custom importers and processors for their game content. For more information about the XNA Framework Content Pipeline, and about content processors in general, see Adding Content to a Game.

Bb203928.note(en-us,XNAGameStudio.40).gifNote
Content Pipeline Extension Library projects require .NET Framework 3.5. This version of the .NET Framework must be selected in the combo box in the upper-right corner of the New Project dialog box. Otherwise, the Content Pipeline Extension Library (4.0) template will not be presented. The .NET Framework 3.5 is the default selection.

The new project contains basic code that implements an empty processor, usable by the XNA Framework Content Pipeline. Solution configurations for all available platforms are created automatically. This means that the Content Pipeline extension project builds processors and importers for any available platform without any change to the project.

Bb203928.note(en-us,XNAGameStudio.40).gifNote
A solution configuration determines which project configurations are active, as well as which projects are built and deployed when you invoke the Build and Run commands. By default, if a project does not have a configuration that matches the active solution configuration, the solution build will skip that project.

In addition to the project template, there are additional code templates related to projects of this type. You can use the Add New Item dialog box to add these items to your project. Here are some basic descriptions:

Content Processor item

An item template comprised of a single code file (called ContentProcessorN.cs). The numerical suffix (N) guarantees uniqueness within the project. This file is similar to the ContentProcessor1.cs file created for the Content Pipeline Extension Library (4.0) template. The file declares a class derived from ContentProcessor with an override of the abstract Process method.

Content Importer item

An item template comprised of a single code file called ContentImporterN.cs. The numerical suffix (N) guarantees uniqueness within the project. The file declares a class derived from ContentImporter with an override of the abstract Import method.

Content Type Writer item

An item template comprised of a single code file called ContentTypeWriterN.cs. The numerical suffix (N) guarantees uniqueness within the project. The file declares a class derived from ContentTypeWriter with overrides of the abstract Write and GetRuntimeReader methods.

Content Type Reader item

An item template comprised of a single code file called ContentTypeReaderN.cs. The numerical suffix (N) guarantees uniqueness within the project. The file declares a class derived from ContentTypeReader with an override of the abstract Read method.

Unlike the Content Type Writer item, this item is unavailable when adding a new item to a Content Pipeline Extensions Library project. It is only available for game or game library projects.

Whenever items of this type are added to a project, references to any dependent assemblies are added automatically. These references include assemblies that are likely to be required when customizing the newly-added class.

Results

The new starter project contains the following important features.

Bb203928.UsingXNA_SolutionExplorer_CPExt_Library(en-us,XNAGameStudio.40).jpg

Project Properties

These properties control many aspects of your current project. Some examples include general application settings, debug settings, and additional project resources. You can modify the values for these properties using the Project Designer.

In addition to these properties, assembly information (such as the library title) is stored in the AssemblyInfo.cs file. This information can be modified using the Assembly Information dialog box or manually editing the .cs file.

References

References to the following assemblies are added automatically to a new Content Pipeline Extension Library project:

  • Microsoft.Xna.Framework
  • Microsoft.Xna.Framework.Content.Pipeline
  • Microsoft.Xna.Framework.Game
  • System
  • System.Core
  • System.Xml
  • System.Xml.Linq

In addition to these standard assemblies, you can add other assemblies as needed for your project.

ContentProcessor1.cs File

This file implements an empty C# processor within a namespace, providing a starting point for the custom content processor.

To create a Content Pipeline Extension Library (4.0) project

  1. On the File menu, click New Project.

  2. Select the Content Pipeline Extension Library (4.0) project type.

  3. Type the name for the library project in the Name box.

    You can also modify the default values for the Location and Solution Name controls.

  4. Click OK to create and load the new project.

Community Additions

ADD
Show:
© 2014 Microsoft