X hits on this document

377 views

0 shares

0 downloads

0 comments

92 / 102

PhoneApplicationService.Current.Activated += new EventHandler<ActivatedEventArgs>(GameActivated);

PhoneApplicationService.Current.Deactivated += new EventHandler<DeactivatedEventArgs>(GameDeactivated);

PhoneApplicationService.Current.Closing += new EventHandler<ClosingEventArgs>(GameClosing);

PhoneApplicationService.Current.Launching += new EventHandler<LaunchingEventArgs>(GameLaunching);

}

This function assigns state saving and restoring handlers to the appropriate events represented by the application level object PhoneApplicationService.Current. Windows Phone provides this object to its applications and raises events in appropriate conditions.

193.

Add to the class the following code fragment that defines event handlers:

C#

#region Event Handlers

/// <summary>

/// Occurs when the game class (and application) launched

/// </summary>

/// <param name="sender"></param>

/// <param name="e"></param>

void GameLaunching(object sender, LaunchingEventArgs e)

{

   ReloadLastGameState(false);

}

/// <summary>

/// Occurs when the game class (and application) exiting during exit cycle

/// </summary>

/// <param name="sender"></param>

/// <param name="e"></param>

void GameClosing(object sender, ClosingEventArgs e)

{

   SaveActiveGameState(false);

}

/// <summary>

/// Occurs when the game class (and application) deactivated and tombstoned

/// </summary>

/// <param name="sender"></param>

/// <param name="e"></param>

void GameDeactivated(object sender, DeactivatedEventArgs e)

Page | 92

Document info
Document views377
Page views377
Page last viewedSun Jan 22 01:41:44 UTC 2017
Pages102
Paragraphs3115
Words17333

Comments