Three kinds of body types for box2d

Source: Internet
Author: User

1.bodytype.staticbody

2.bodytype.dynamicbody

3.bodytype.kinematicbody

The first static body does not move and does not collide with other body, not affected by gravity

The second dynamic body movement, will collide with other body, there will be a corresponding response after the collision, will be affected by gravity

The third kinematics body will not collide with other body, not affected by gravity.

For example: Dynamicbody and other body such as staticbody (wall, etc.) collide, dynamicbody may rebound, movement direction change and so on,

Kinematicbody give her a speed she will exercise, but when the movement passes through the other body, he will not have the same effect as dynamicbody, but through it

Fixturedef boxbodyfixturedef =physicsfactory.createfixturedef (20f, 0f, 0.5f); FinalRectangle Kinematicrectangle =NewRectangle (600f, 100f,40f, 40f, This. Getvertexbufferobjectmanager ()); Kinematicrectangle.setcolor (0.8f, 0.8f, 0f);        Mscene.attachchild (Kinematicrectangle); FinalBody Kinematicbody =physicsfactory.createboxbody (Mphysicsworld,kinematicrectangle, Bodytype.kinematicbody, BOXBODYFIXTUREDEF); Mphysicsworld.registerphysicsconnector (NewPhysicsconnector (Kinematicrectangle, kinematicbody)); Kinematicbody.setlinearvelocity (2, 0); Kinematicbody.setangularvelocity (0.6f);

Three kinds of body types for box2d

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.