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 }}