How do I update the Box2D version in a Cocos2dx project?

I am working on a game with cocos2d-x v2.2 and would like to use the latest version of Box2D. What should I do to accomplish this?

I need to do this because I need access to the e_motorJoint b2JointType.

Thank you for your help.

That’s pretty easy:

  1. Download Box2d 2.3.0 from the official site, blah-blah-blah, that’s obvious.
  2. In cocos2d-x/external/Box2D replace all box2d files with the new ones.
  3. If you are using Android platform, add ’Dynamics/Joints/b2MotorJoint.cpp to LOCAL_SRC_FILES variable in cocos2d-x/external/Box2D/Android.mk.
  4. If you are using MSVC, add Dynamics/Joints/b2MotorJoint.cpp and Dynamics/Joints/b2MotorJoint.h to libBox2D project.
  5. If you are using GCC 4.3*, add ’#include to the following headers:
    * Common/b2GrowableStack.h
    * Common/b2BlockAllocator.h
    This is necessary because GCC 4.3* stopped including and some other standard libs automatically to lower the build time. Don’t know why Erin Catto doesn’t update his code accordingly to this compiler behaviour.

Thank you very much, this is very helpful :slight_smile:

Why don’t you guys create a pull request to include this for all? :slight_smile:

dot squid wrote:

That’s pretty easy:

  1. Download Box2d 2.3.0 from the official site, blah-blah-blah, that’s obvious.
  2. In cocos2d-x/external/Box2D replace all box2d files with the new ones.
  3. If you are using Android platform, add ‘Dynamics/Joints/b2MotorJoint.cpp’ to LOCAL_SRC_FILES variable in cocos2d-x/external/Box2D/Android.mk.
  4. If you are using MSVC, add Dynamics/Joints/b2MotorJoint.cpp and Dynamics/Joints/b2MotorJoint.h to libBox2D project.
  5. If you are using GCC 4.3*, add ’#include to the following headers:
    * Common/b2GrowableStack.h
    * Common/b2BlockAllocator.h
    >
    This is necessary because GCC 4.3* stopped including and some other standard libs automatically to lower the build time. Don’t know why Erin Catto doesn’t update his code accordingly to this compiler behaviour.

Just wondering if LiquidFun could be added this way? any idea? would be great if you could post a how-to? thanks:-)