SpriteHand
Module Border
  WP7 Back Button in Games
Module Border
Location: BlogsAndy'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.


Title:
Comment:
Add Comment   Cancel 
Module Border Module Border
Module Border
  Subscribe
Module Border
RSS   Twitter
Module Border Module Border
Module Border
  Diversions
Module Border

TALKING RAGDOLL
This Windows Phone 7 App was created using Silverlight, the  Physics Helper Library,  and the Farseer Physics Engine. It gets interesting when you import your friends photos and have your way with them!

MORE INFO



DROPPYPOP
This Windows Phone 7 game was created using Silverlight, the  Physics Helper Library,  and the Farseer Physics Engine.
DEMO

MORE INFO



BOSS LAUNCH
This physics game won first place in the Server Quest Contest. Created using Silverlight 2, the Physics Helper Library,  and the Farseer Physics Engine.
PLAY IT

MORE INFO



DESTROY ALL INVADERS
A scrolling shooter game where the objective is to destroy the invading UFO's flying over a neighborhood of your choosing. Imagery provided by Microsoft Virtual Earth. Created using Silverlight 2.
PLAY IT

INFO AND CODE



PHYSICS HELPER DEMOS
These demos were created for the Physics Helper Library, which makes it easy to create physics games and simulations using Expression Blend, Silverlight, and the Farseer Physics Engine.
PLAY IT

INFO AND CODE



HOOK SHOT
This little basketball game took first place in the TeamZoneSports Silverlight Contest. Created using Silverlight 2 and the Farseer Physics engine.
PLAY IT

MORE INFO



SORT THE FOOBARS
A game where you need to sort the good foobars from the bad ones. Created using Silverlight 2 and the Farseer Physics engine.
PLAY IT

MORE INFO



POLYGON PHYSICS DEMO
A demo showing polygon physics where the user draws physics objects with the mouse. Created using Silverlight 2 and the Farseer Physics engine.
PLAY IT

MORE INFO



SILVERLIGHT ROCKS!
Destroy the asteroids before they destroy your ship! Created using Silverlight 2.
PLAY IT

INFO AND CODE



FISH GAME
A simple game of harpoon-the-fish. Written using the AJAX Sprite Toolkit.
PLAY IT

INFO AND CODE

Module Border Module Border
Module Border
  Search_Blog
Module Border
Module Border Module Border
Module Border
  Blog_Archive
Module Border
Module Border Module Border
Copyright (c) 2013 andy.beaulieu.com - Login