soleil
soleil

Reputation: 13083

Box2d - how to grab and throw objects

Say there are 3 boxes on the screen, how can I go about touching one of them to pick it up and "throw" it at the others? I have the rest of the world implemented but can't find much information on how to grab/drag/toss physics objects. Any sample code or documentation out there that would help with this?

Upvotes: 0

Views: 834

Answers (1)

madmik3
madmik3

Reputation: 6973

It depends what you are attempting to do. It is a physics simulation and as such a typical way of interacting with the system is by applying forces to objects opposed to direct manipulation of the x,y coordinates. But you can in fact do either. I believe the most common approach is to use a mouse joint. A google search on b2MouseJoint will show the documentation and several examples including this one.

http://muhammedalee.wordpress.com/tag/b2mousejoint/

Upvotes: 1

Related Questions