Introduction to Gamer Services

The GamerServices namespace provides functionality for working with Xbox LIVE, including querying for Xbox LIVE accounts, working with gamer avatars, retrieving player preferences for local accounts, and showing various Xbox LIVE user interface screens programmatically.

Bb975583.note(en-us,XNAGameStudio.41).gifWindows Specific Information

Games for Windows - LIVE is unavailable to finished games. This functionality is not included in the redistributable version of the XNA Framework. A game that attempts to use these components without XNA Game Studio installed will result in a GamerServicesNotAvailableException.

  • Initialization of Gamer Services
  • Player Sign In
  • Gamer Avatar
  • Player Profile Information
  • Guide User Interface

Initialization of Gamer Services

Users must explicitly initialize the gamer services subsystem before they can use any gamer services or networking API calls. Most games will use the GamerServicesComponent, a game component that takes care of the process of initializing and pumping the gamer services system. This component automatically will pass through the graphics device and window handle. It calls Update to pump the gamer services pump at regular intervals. To take advantage of this component, most games simply need to add one line to the Game constructor:

Components.Add(new GamerServicesComponent(this));

Initializing the gamer services system can be a slow operation, and it has user-visible consequences. For example, the game may display the "Player Signed In" notification when the gamer services system is initialized. This happens when a local profile is set to sign in automatically, which triggers a system update. Because of this, it is desirable to initialize everything in the game startup code in the constructor if a game is going to use these services.

Programs that do not use the XNA Framework application model or component infrastructure can use GamerServicesDispatcher. In this case, you must also call the GamerServicesDispatcher.Initialize and GamerServicesDispatcher.Update methods directly. Under these conditions, you should initialize the GamerServicesDispatcher once at startup, and call GamerServicesDispatcher.Update at every frame.

The GamerServicesDispatcher.Update method enables the XNA Framework to raise events for notifications such as sign-in status changes and game invites when it is safe to raise the events.

Player Sign In

For standard game clients with a user interface, the Guide user interface automatically displays the appropriate user interface when a player presses either the HOME key on the keyboard or the Guide button on the Xbox 360 Controller, allowing players to sign in. Before a player signs in, you also can choose to manually display the sign-in user interface by using the Guide.ShowSignIn function.

When a SignedInGamer signs in, the SignedInGamer.SignedIn event occurs. You can get the list of players signed in at any time using the static property Gamer.SignedInGamers.

Gamer Avatar

Avatars are three-dimensional animated characters that represent the gamer in a versatile, personalized, engaging manner. Gamer services implements support for displaying and animating a gamer's avatar using standard effects and animations. In addition, access to an avatar's metadata (such as hierarchy information and textures) allows developers to implement custom rendering and animating of a gamer's avatar.

Note

Avatar support is available only for Xbox 360 applications or Windows Phone titles approved to access Xbox LIVE Services through the Xbox LIVE Registered Developer Program.

Avatars are used in a variety of ways on the Xbox 360 console: as a gamer picture and integrated into the friends list display, the Xbox Guide, and the dashboard. Also, game titles can use avatars in-game to represent various game players and to provide unique spectators, cut scene actors, crowd members, or game characters.

For more information about implementing avatar support in your application, see Avatars.

Player Profile Information

The player profile information accessible BY using the Gamer.GetProfile method returns information such as the gamer picture, motto, and gamer zone. Specifically, the gamer profile provides the following information about a gamer:

You may use SignedInGamer.GameDefaults to retrieve a local gamer's preferred settings, such as:

Using SignedInGamer.Privileges, you can see if the player is allowed to:

You can also view if a gamer is LIVE-enabled or a guest.

Privileges are enforced by the framework. A player can never create an online session if his or her multiplayer privilege is not enabled. We provide programmatic access to these settings so that games may check to see if anything is forbidden. In such a case, the relevant menu options are dimmed (meaning unavailable)—this keeps the user from selecting a forbidden option and getting an exception or error when trying to call the forbidden method.

Guide User Interface

The XNA Framework exposes a property, Guide.IsVisible, which checks to see if the Guide user interface is active. The Guide runs independently alongside games. The player can view the Guide at any time by pressing the HOME key on the keyboard or the Guide button on the controller.

Many of the Guide calls are blocking. The XNA Framework uses the standard .NET async pattern to expose asynchronous versions of all the Guide methods. Blocking versions of the Guide methods automatically pump the graphics device while the UI is active. They call GraphicsDevice.Present at regular intervals with an empty (black) back buffer. Games should have the asynchronous versions of the methods if it is desirable to continue rendering behind the Guide. The existing storage device UI has been changed to match the new design.