Bodya and bodyb of box2d b2mousejoint

Source: Internet
Author: User

Link: http://blog.csdn.net/zhangxaochen/article/details/8009457

I was reading this tutorial:

Http://www.raywenderlich.com/475/how-to-create-a-simple-breakout-game-with-box2d-and-cocos2d-tutorial-part-12

Http://www.cnblogs.com/andyque/archive/2011/05/27/2059460.html

It says:

After you create a mouse joint, you assign two bodies to it. The first is not used. It is usually set to the ground body. The second one is the body you want to move. In this example, It is paddle.

I am wondering, it is understandable that bodyb is set to the object we want to drag, but must bodya be set to groundbody? Can I write null if I just get used to it?

Experiment:

1. If mjdef. bodya = NULL; then, when the program is running, touch the screen and the program will be suspended.

2. if mjdef. bodya = _ world-> createbody (New b2bodydef); that is, you can create a new body. [The default coordinate is (0, 0)], set it to bodya, and drag it normally.

3. if:

b2BodyDef zBody;zBody.position.Set(1, 1);mjDef.bodyA=_world->CreateBody(&zBody);

Create a new body, set the coordinates to (), add it to bodya, and drag it normally

==========================================

It seems that bodya does not matter to the caller. It should be used to set a reference point for bodyb.
Link: http://blog.csdn.net/zhangxaochen/article/details/8009457

{Over }}

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.