Problem using NavigationService.GoBack()

Nov 23, 2010 at 4:50 PM

Hi all,

Ive been using the Physicshelper to get a game up on Windows Phone 7.  Its a great library and a joy to use.  However I am having a problem.

I have physics on my MainPage.cs, then i use navigate to get to another screen (with no physics), i then use NavigationService.GoBack() and i return to the mainpage, however the physics objects are still there, but no collisions happen anymore.  I have tried using .PauseSimulation when navigating away and then enabling it again, but the same problem occurs.

Do you know what might be causing this?

Nov 26, 2010 at 8:23 PM

I am experiencing the same problem. For me PhysicsObjects collection in PhysicsControllerMain is empty when i use GoBack(), or use the hardware back button.

Rune

 

 

Coordinator
Nov 30, 2010 at 11:22 PM

I just checked in a fix to this - you'll need to download the source code Change Set 60458 for now, I won't do a new release until a few more enhancements are made.

Also keep in mind, you probably want to Pause/Resume the Simulation when navigating from/to the page. Here is some sample code for that:

protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)

{

    base.OnNavigatedTo(e);

 

    PhysicsControllerMain physicsController = PhysicsControllerMain.FindController(ucMainGame1.cnvGame);

    physicsController.PauseSimulation = false;

}

 

protected override void OnNavigatedFrom(System.Windows.Navigation.NavigationEventArgs e)

{

    base.OnNavigatedFrom(e);

 

    PhysicsControllerMain physicsController = PhysicsControllerMain.FindController(ucMainGame1.cnvGame);

    physicsController.PauseSimulation = true;

           

}

                       

 


Dec 1, 2010 at 10:30 AM
Edited Dec 1, 2010 at 10:59 AM

Thanks Andy.  I'll try this out this morning.

 

UPDATE: Works great, thanks ;)