Game Development Reference
In-Depth Information
The process continues in the same way as before, with the assignment of bodyA and
bodyB properties, in this case the last box we created and the ground body:
rJoint.bodyA=box4;
rJoint.bodyB=world.GetGroundBody();
Now, the local anchor points relative to the bodies, in this case the origin of the box
and the same point in world coordinates.
rJoint.localAnchorA=new b2Vec2(0,0);
rJoint.localAnchorB=box4.GetWorldCenter();
And now, the creation of the revolute joint itself:
var revoluteJoint:b2RevoluteJoint;
revoluteJoint=world.CreateJoint(rJoint) as b2RevoluteJoint;
Test the movie and interact with the newly created box: try to drag it, place the other
boxes over it, do anything you want. There is no way to move it, as it will just rotate
around its anchor point.
There are more types of joints supported by Box2D, but listing and explaining all
joints is beyond the scope of this topic. I want you to learn how to make Box2D
powered games, and with mouse, distance, and revolute joints you can already do
almost everything you want. Refer to the official docs for the complete list of joints
http://box2d.org/manual.pdf .
 
Search WWH ::




Custom Search