Cocos2d-x set enable box2d in Visual Studio and Eclipse, respectively

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.