XNA - Getting GamerCard Info in Xbox 360

One nice XNA feature is the ability to manage Xbox 360 users gamer data. This way you can access your gamercard information which include your name, avatar, achievements, played games and list of friend among other things. How can you do that?
In the Initialize method of your game you must add a specific component into the game, in order to prepare the game to access the data.

Since while the Initialize and LoadContent methods are executed, the gamer data is not available yet, you must access it in the Update method. There you can check if a variable is set, and if it is not, you load the gamercard information. Be careful, you must not load the gamer data in every iterations of the game loop. Your Xbox will hang if you do that… It is an expensive operation. Try to load this data only one time or so during the game lifetime.

This example show your gamer picture in the screen, followed by some of your informations such as your gamer tag.

You can download the full source code and deploy it into your Xbox 360 console and give it a try. (I’ve written before about how to get a free XNA Creators Club Membership in order to allow XNA deploying).


