In fact, this is the three classes of Physicsworld class, Physicsbody class, Physicsshape class.
1.PhysicsWorld class
The Physicsworld object represents the physical world in Cocos2d-x, a world that can be used to simulate collisions and other physical properties. Instead of creating a Physicsworld object directly, it is recommended to get the Physicsworld object from a Scene object, Scene->getphysicsworld ().
2.PhysicsBody class
The Physicsbody object represents a rigid body in the physical world, and a rigid body can be attached to one or more shapes. If you create a rigid body object through the createxxx () function, the mass and torque are automatically calculated based on the density.
3.PhysicsShape class
The Physicsshape object represents the shape of a rigid body and some other properties that can be set to some density, mass, elasticity, and so on.
To set up a rigid body for an Elf object:
1. Create a Sprite object ball
2. Create a Body body
3. Adjust the properties of this rigidbody with the Physicsshape pointer object
Physicsshape *ps=body->getshape (0);
Ps->setmass (0.2f);
...
4. Set the body properties of this sprite object
Ball->setphysicsbody (body);
5. Add this Sprite object to the layer
This->addchild (ball);
The 13th chapter of the book on the Code of the physical world test that part, I feel very likely the author is to use gravity sensor on the phone to control the object or to achieve gravity, so wrote the device accelerometer method and accelerometer listener.
About the classes used by the Cocos2d-x physics engine and the use