 |
|
 |
|
Location: Blogs Andy's Blog |
|
| Posted by: host |
6/14/2010 6:35 PM |
In order to publish a Windows Phone 7 application on the Marketplace, your app must pass a list of certification requirements. One of the items in the Windows Phone 7 Certification Requirements caught my eye:
5.2.4 Use of Back Button in Games
a. Pressing the Back button from the first screen of a game must exit the application.
b. During gameplay, pressing the Back button in games must present an in-game menu. This menu must offer the option to resume the game. Pressing the Back button while this menu is up must exit the game. Microsoft recommends that you save the user game state or warn them of possible progress loss before exiting the game).
c. Outside gameplay (for example, when the user is viewing the options or help menu), pressing the Back button must return to the previous menu or page.
In order to conform to this requirement in a Silverlight game, we can override the OnBackKeyPress event of a PhoneApplicationPage, and if the game is playing we can present the user with a "pause menu" allowing them to resume or exit the game. Here is an example of an OnBackKeyPress override that I'm using to show an in-game menu.
protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)
{
if (ucMainGame1.GameState == ucMainGame.GameStates.Playing)
{
e.Cancel = true;
ucMainGame1.PauseGame();
}
}
To stop our app from closing due to the back button key press, we just set e.Cancel to true.
That's all there is to it. If your app has some deeply nested screens, for options and such, you will likely want to navigate to the screens using a NavigateUri property of a Hyperlink control. This way, the back button will take you back to previous pages and fulfill requirement 5.2.4.c.
|
|
| Permalink |
Trackback |
Comments (7)
Add Comment
|
Re: WP7 Back Button in Games
|
By Anonymous on
6/14/2010 9:10 PM
|
Neat Point.
Thanks.
KRK
|
|
|
Re: WP7 Back Button in Games
|
By Anonymous on
6/14/2010 10:17 PM
|
|
nice find.
|
|
|
Re: WP7 Back Button in Games
|
By Anonymous on
6/15/2010 6:32 AM
|
Hi Andy, you have a lot of great stuff on your site, but it would be great if you could do something as a beginner video tutorial for your's Physics Helper Library for windows phone 7(how to add it to a project, simple use of it,if there are any things to watch out,etc). keep up the good work
|
|
|
Re: WP7 Back Button in Games
|
By Anonymous on
6/17/2010 1:45 AM
|
|
About my upper comment "Coding4Fun article Creating a Shuffleboard Game" was exactly what I was looking for, tnx for the great stuff again. Greetings from Slovenia :]
|
|
|
Re: WP7 Back Button in Games
|
By Anonymous on
8/22/2010 11:36 AM
|
Andy, how have you implemented the "Exit Game" portion of this when the in game menu is showing and the user hits the back button?
I posted this question in the WP7 forums as well:
http://social.msdn.microsoft.com/Forums/en-US/windowsphone7series/thread/298219ae-929b-4ec7-9719-e61c30a5c869
|
|
|
Re: WP7 Back Button in Games
|
By Anonymous on
12/13/2010 4:11 PM
|
|
This is OLD, look at the new guidelines
|
|
|
Re: WP7 Back Button in Games
|
By Anonymous on
12/14/2010 7:19 AM
|
In the new requirements, the wording makes it sound like the Pause menu is now optional? Otherwise it is similar to the old requirements.
5.2.4 (d) For games, when the Back button is pressed during gameplay, the game can choose to present a pause context menu or dialog or navigate the user to the prior menu screen. Pressing the Back button again while in a paused context menu or dialog closes the menu or dialog.
|
|
|
|
 |
|
 |
|
|