Cocos2d-x is embedded with the chipmunk and box2d two physical libraries, chipmunk is enabled by default. If you want to use box2d, you can do the following settings. PS: I use the version is cocos2d-x-2.2.5.
One, set enable box2d in Visual Studio.
You typically create a project by using the Python command under the tools/project-creator/folder in the Cocos2d-x home directory, and when you open the project, the associated libraries are also imported into visual Studio. Settings are as follows:
1, select the project, press ALT + ENTER shortcut key (or right-click, select Propreties), in the pop-up menu, choose c + +--preprocossor, will preprocessor definition under the Cc_enable_ Chipmunk_integration=1 modified to Cc_enable_box2d_integration=1.
2, see Linker-->input under the aditional dependencies, there is no libBox2d.lib. If not, add it manually.
3, this point is also noteworthy. The Ccphysicssprite class, which links an elf to a rigid body, once a Ccphysicssprite object is created, the position changes of its sprite and rigid body are automatically updated without us having to update it manually. And it is easy to get the genie from the rigid body, and the elf to get the rigid body. It is recommended to use this class. Ccphysicssprite a lot of tutorials, but no one mentions some of the corresponding settings.
If you use this class, because it is defined in the Libextensions library, followed by the previous two steps, when you use the class, if you call box2d to create its rigid body, you will get an error, because the Libextensions library's default physical engine is still chipmunk. You want to set up the library further. The Setup method is the same as the previous two steps, except that the set object becomes the Libextensions class library instead of the project that you created.
Ii. setting up the startup box2d in Eclipse
1. Open the JNI directory under the project directory, open the Application.mk file, and modify the-dcc_enable_chipmunk_integration=1 in the file to-dcc_enable_box2d_integration=1
2. Similarly, if you use Ccphysicssprite, open the Android.mk file in the extensions directory and modify all-dcc_enable_chipmunk_integration=1 in the file to-dcc_ Enable_box2d_integration=1
Cocos2d-x set enable box2d in Visual Studio and Eclipse, respectively