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
- Open an XNA Framework game or library project in XNA Game Studio Express.
- In Solution Explorer, right-click the game project node.
- Click Add and then click New Item.
- Select the Game Component icon.
- Enter a name for the source file, and then click Add.
The new code is composed of three main methods.
||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.|
||Called by the framework when the component starts. Add component-specific starting code here.|
||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.