Giving force to an object or user control

Jul 17, 2011 at 3:33 PM

How do you make an ellipse do this? I created an ellipse and named it "testEllipse" and dragged the PhysicsObjectBehavior onto it. So I want to move it point a to point b when an event is triggered. The problem is when it gets to the PhysicsSprite line it says it can't find "testEllipse" key. How do find the physics object?


PhysicsSprite temp = physicsController.PhysicsObjects["testEllipse"] as PhysicsSprite;

temp.BodyObject.ApplyForce(new Vector2(new Vector(Point2.X,Point2.Y), new Vector(Point1.X,Point1.Y)));
Jul 18, 2011 at 1:11 AM

Please help anyone? All I'm trying to figure out is how to apply force to a physics object. It doesn't seem to go by the name given in the xaml though and I'm not sure what to do.

Jul 18, 2011 at 3:01 AM

Could be a couple of things, double check that the physics object is attached to the ellipse and not the parent container.

Also double check that the physics controller is initialised and has physics objects in it. I think there’s an event you can hook into that fires after it’s intitalised.

Check those things and then maybe post a code sample, it’s hard to tell what’s wrong with two lines of code.

Jul 18, 2011 at 11:55 PM

I added the physics controller initialize event and now it works. I'm not sure how though