GameComponents

Purpose

These allow you to add modularity to your game, and come in two flavors, GameComponent and DrawableGameComponent.

GameComponents are also used in the concept of a Scene.

The basic example is you create a component for your player. Since the player is actually shown on the screen, it would be based off the DrawableGameComponent. Now, the player pauses the game, and you don't want the player to see his position, so you set the visible property to false, when the player unpauses the game, the players component visible is set to true.

Example

Assume Hero is derived from a GameComponent or a DrawableGameComponent.

player = new Hero(agr1, agr2, agr3);
Components.Add(player);
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License