public Game1()
{
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
this.Components.Add(new GamerServicesComponent(this));
}
IAsyncResult result;
Object stateobj;
bool GameSaveRequested = false;
GamePadState currentState;
protected override void Update(GameTime gameTime)
{
GamePadState previousState = currentState;
currentState = GamePad.GetState(PlayerIndex.One);
// Allows the default game to exit on Xbox 360 and Windows
if (currentState.Buttons.Back == ButtonState.Pressed)
this.Exit();
if ((currentState.Buttons.A == ButtonState.Pressed) &&
(previousState.Buttons.A == ButtonState.Released))
{
// Set the request flag
if ((!Guide.IsVisible) && (GameSaveRequested == false))
{
GameSaveRequested = true;
result = Guide.BeginShowStorageDeviceSelector(PlayerIndex.One,
null, null);
}
}
// If a save is pending, save as soon as the
// storage device is chosen
if ((GameSaveRequested) && (result.IsCompleted))
{
StorageDevice device = Guide.EndShowStorageDeviceSelector(result);
if (device != null && device.IsConnected)
{
DoSaveGame(device);
}
// Reset the request flag
GameSaveRequested = false;
}
base.Update(gameTime);
}