Windows apps
Collapse the table of content
Expand the table of content
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Game Component Development

You can use XNA Game Studio Express to develop custom game components for use in your game projects. You do this by deriving the new component either from the GameComponent class, or, if the component loads and draws graphics content, from the DrawableGameComponent class. For additional information about existing game component support in the XNA Framework, see the Game Components section of Application Model Overview.

Developing Custom Components

XNA Game Studio Express supports the development of custom game components for use in your game code. You can insert basic code for implementing a new component using the Add New Item dialog box. The following procedure lists the steps involved.

To insert a new custom game component

  1. Open an XNA Framework game or library project in XNA Game Studio Express.
  2. In Solution Explorer, right-click the game project node.
  3. Click Add and then click New Item.
  4. Select the Game Component icon.
  5. Enter a name for the source file, and then click Add.

The new code is composed of three main methods.

Method NamePurpose
GameComponent1 The constructor for the game component. The name matches the name you specified when inserting the new component. Add code that initializes the component here.
Initialize Called by the framework when the component starts. Add component-specific starting code here.
Update Called by the framework when the component needs to be updated. Add component-specific update code here.

After creating the new component, add custom code to provide the necessary functionality.

© 2018 Microsoft