Start Gravity with Button Click

Oct 26, 2011 at 6:29 AM

I want to be able to use PhysicsHelper and add object via Blend, but then not have them repond to gravity until I click a "Start" button.

Oct 26, 2011 at 12:49 PM

On the PhysicsControllerBehavior, set GravityHorizontal and GravityVertical equal to "0"

In your button Click event, add code to set the gravity -

PhysicsControllerMain _physicsController = cnvGame.GetValue(PhysicsControllerMain.PhysicsControllerProperty) as PhysicsControllerMain;


                Vector2 newVector = new Vector2();

                newVector.X = 0;
                newVector.Y = 10;

                _physicsController.Simulator.Gravity = newVector;