How to add physicsBehaviors to an exist User Control Programmatically?

Dec 8, 2009 at 12:45 PM

How to add physicsBehaviors to an exist User Control  Programmatically?

Is there a demo which shows how to add physicsBehaviors to an exist User Control  Programmatically?

For example,at first,a User Control named "truck" doesn't have the physics properties,but after click a button "btn",the "truck" become a physics object.

I need a simple demo which like above said,and shows how to "Adding Physics Behabiors Programmatically" in the page "http://www.andybeaulieu.com/Home/tabid/67/EntryID/168/Default.aspx"

Thanks a lot !

 

Jun 7, 2010 at 6:52 AM

Try this...

PhysicsObjectBehavior obj = new PhysicsObjectBehavior();
 
 BehaviorCollection behaviours = Interaction.GetBehaviors(_truck_image);
behaviours.Add(obj);
 
 _physicsMain.AddPhysicsBody(_truck_image.GetValue(PhysicsObjectMain.PhysicsObjectProperty) as PhysicsObjectMain);

 


 ittiGator Physics game is now on Facebook http://apps.facebook.com/ittigator