Box2D 2.1a “Rope Joint” ported to AS3

Box2D 2.1a Rope Joint for AS3

You may have noticed that the original C++ version of Box2D is now up to version 2.2.1. As of version 2.2.0 there were a few additions, one of which being a b2RopeJoint. For ActionScript 3.0 users the only choice to incorporate this feature was to use the Alchemy generated Box2D port. Developers using Box2DFlashAS3 by BorisTheBrave unfortunately did not have this as the port is of version 2.1a. That is, until now.

Because I am using the HaXe version of Box2D which is based off the Box2DFlashAS3 I needed it, and, from my searches on the internet, there seemed to be a few people who were still using Box2DFlashAS3 but wanted the Rope Joint. Hopefully this will help those people out. I have also updated my joints tutorial to incorporate the rope joint.

Installation instructions: Save these files into the Box2D\Dynamics\Joints folder. b2Joint will overwrite the existing b2Joint.

Update 1.01: Fixed bug when not setting anchor to centre and having zero gravity.




  • q13

    Will be great if you add demo

  • allanbishop

    See this post and click on the picture to view the swf demonstrating the various joints. It is the third one along :)

    EDIT: Realised I had uploaded everything except the updated swf file. Has now been fixed.

  • q13

    Cool. Thanks.

  • hencca


  • Jamie

    Really like this idea for a rope, instead of using loads of physics bodiesIs it possible to detect if the rope has be split and remove the joint?

  • allanbishop

    So for implementing something like cut the rope? That being the case it is a bit tricky. To make the rope look like a rope we would use verlet integration for drawing the actual rope segments. While this looks realistic each rope line segment will not collide with our physics world (only the two end points). So one solution would be to do a line intersection detection against the verlet system rope segment points and remove if they intersect.

  • Jamie

    Cheers for the quick reply
    Will have a play with that idea, seems a lot better than the route I was going to take

  • k1rsan

    Thanks a lot for these Classes!

    My name is Kirill. I am a Flash game developer.
    I am currently trying to load the level from the R.U.B.E with all types
    of bodies and joints. I have some difficulties with loading joints.

    Your port of RopeJoint really helped me.

    In the last version of Box2D C++ there is a joint named MotorJoint and I have not found the way how to replace this joint with already existing ones. I do not know the Box2D engine as good as you do and I will need a lot of time to port it.

    Could you be so kind to port this joint? Of course, in case if you have free time.

    This is the only one joint, that does not exist in FlashBox2D engine version, which is needed to load all scenes, that you can create in the R.U.B.E (Really Usefull Box2d Editor).

    Your help would be greatly appreciated!


  • allanbishop

    Hi Kirill,

    Glad the classes have helped. I wish I did have time to port the MotorJoint but I am afraid I don’t and probably wont have for quite a while :( However, you may find it easier to port for yourself than you think. The way I ported the RopeJoint was to compare a similar joint to RopeJoint in C++ to the AS3 version that existed. Once I figured out what each line of code was equivalent to, I then looked at the similar joint in C++ and compared it to the C++ Rope Joint. That way I could see what needed to be added and I had already a blueprint of what the AS3 corresponded to in C++ (and vice versa). I recommend using a program like WinDiff to help show the differences between the C++ files

    Hope that helps

  • k1rsan

    Thak you for reply!

    I have not thought about program like this :))

    I will try to port this MotorJoint by myself.