Compiling the box2d code in the Win32/android development environment

Source: Internet
Author: User
<span id="Label3"></p><p><p>Two physical engines were introduced in Cocos2d-x: Chipmunk and Box2d.</p></p><p><p>For these two engines, Cocos2d-x provides a ccphysicssprite class associated with it, but because only one engine can be used, the choice is made in a macro-defined way. Like what:</p></p><pre><span style="color: #0000ff;"><span style="color: #0000ff;">class</span></span>Ccphysicssprite:<span style="color: #0000ff;"><span style="color: #0000ff;"></span> public</span><span style="color: #000000;"><span style="color: #000000;">ccsprite{</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">protected</span></span><span style="color: #000000;"><span style="color: #000000;">: </span></span><span style="color: #0000ff;"><span style="color: #0000ff;">BOOL</span></span><span style="color: #000000;"><span style="color: #000000;">m_bignorebodyrotation;</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">#if</span></span>Cc_enable_chipmunk_integration<span style="color: #000000;"><span style="color: #000000;">Cpbody</span></span>*<span style="color: #000000;"><span style="color: #000000;">m_pcpbody;</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">#elif</span></span>Cc_enable_box2d_integration<span style="color: #000000;"><span style="color: #000000;">B2body</span></span>*<span style="color: #000000;"><span style="color: #000000;">m_pb2body; </span></span><span style="color: #008000;"><span style="color: #008000;">//</span></span><span style="color: #008000;"><span style="color: #008000;">Pixels to Meters ratio</span></span> <span style="color: #0000ff;"><span style="color: #0000ff;">float</span></span><span style="color: #000000;"><span style="color: #000000;">m_fptmratio;</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">#endif</span></span> <span style="color: #008000;"><span style="color: #008000;">//</span></span><span style="color: #008000;"><span style="color: #008000;">cc_enable_chipmunk_integration<br>The following ellipsis</span></span></pre><p><p>The above is the definition code snippet for the Ccphysicssprite class, which can be seen to support both Chipmunk and Box2d. <span style="color: #ff0000;"> <strong>however, It is important to note that the physical engine selected by default is Chipmunk. </strong></span></p></p><p><p><span style="color: #ff0000;"><span style="color: #000000;">therefore, If you choose to use box2d encoding without modifying the default macro definition, a compilation error occurs.</span><strong><br></strong></span></p></p><p><p><strong><span style="color: #ff0000;"><span style="color: #000000;">Modifying methods under the Win32 platform</span></span></strong></p></p><p><p><span style="color: #ff0000;"><span style="color: #000000;">In Visual Studio 2012, Select the project properties, c/c + + preprocessor, and then edit the preprocessor definition,</span></span></p></p><p><p></p></p><p><p><span style="color: #ff0000;"><span style="color: #000000;">Modify the Cc_enable_chipmunk_integration value to 0 (delete also can), add cc_enable_box2d_integration=1</span></span></p></p><p><p><strong><span style="color: #ff0000;"><span style="color: #000000;">How to modify Android platform</span></span></strong></p></p><p><p><span style="color: #ff0000;"><span style="color: #000000;">1. Modify the Application.mk file in the JNI directory of the Android project to change the chipmunk in The-dcc_enable_chipmunk_integration=1 to box2d;</span></span></p></p><p><p><span style="color: #ff0000;"><span style="color: #000000;">2. Modify the Android.mk file in the Extensions folder under the engine root directory (note that it is not the android.mk below jni), and the following code is available in lines 141 through 144:</span></span></p></p><pre><pre>Local_cflags + =-dcc_enable_chipmunk_integration=<span style="color: #800080;">1</span><span style="color: #000000;"></span>+ =-<span style="color: #000000;">dcc_enable_chipmunk_integration</span>= <span style="color: #800080;">1</span> <span style="color: #000000;"></span> + =-dcc_enable_chipmunk_integration=<span style="color: #800080;">1</span><span style="color: #000000;"></span>+ =-dcc_enable_chipmunk_integration=<span style="color: #800080;">1</span></pre></pre><p><p>Change the chipmunk to Box2d.</p></p><p><p>PS: Here I use the cocos2d-x-2.2.2 version, not clear the other version of the file directory Situation.</p></p><p><p>In addition, because there is no other platform development, so there is no research on the other platform modification methods. But I think it's all about making Changes.</p></p><p><p></p></p><p><p>Compiling the box2d code in the Win32/android development environment</p></p></span>
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.