Sdílet prostřednictvím


How To: Initialize and Update the Gamer Services Dispatcher

Describes how an application would use the GamerServicesDispatcher instead of the GamerServicesComponent for cases in which a program may not be using the XNA Framework application model or component infrastructure.

Automatically Updating the Gamer Services Dispatcher

The XNA Framework provides a GamerServicesComponent. This is a game component that automatically takes care of initializing and updating the gamer services dispatcher. To make use of this component, XNA Framework games need to add only one line of code to the Game constructor.

To automatically update the gamer services dispatcher

  • To make use of this component, add this line of code to the Game constructor:

    Components.Add(new GamerServicesComponent(this));
    

Manually Updating the Gamer Services System

In some cases a program might not use the XNA Framework application model or component infrastructure. For this application, it is possible to call the GamerServicesDispatcher directly.

To manually initialize and update the gamer services system

  1. Once, in the startup code for the application, call GamerServicesDispatcher.Initialize to initialize the gamer services subsystem.

    protected override void Initialize()
    {
        GamerServicesDispatcher.WindowHandle = Window.Handle;
    
        GamerServicesDispatcher.Initialize(Services);
    
        base.Initialize();
    }
    
  2. Call GamerServicesDispatcher.Update once every frame to update the gamer services system.

    protected override void Update(GameTime gameTime)
    {
        GamerServicesDispatcher.Update();
        base.Update(gameTime);
    }
    

See Also

Concepts

Gamer Services Overview