Recently see some cocos2d-js things, use the chipmunk of some of the things, because the relevant information is not very detailed, so see something useful on the record.
1. Chipmunk is a physical engine of the cocos2d that simulates the reality of gravity, collisions, and so on.
A chipmunk body represents an object in a virtual space and may contain one or more chipmunk shapes to form its geometry.
For example, a dynamic Chipmunk object is added to the scene:
Initialization
This.body = new CP. Body (1, Cp.momentforbox (Mass, boxsize.width, boxsize.height));
Set Position:
THIS.BODY.P = CC.P (loaction);
Use CP. Body to create an object requires two parameters, namely the mass mass and the moment of inertia, and Cp.momentforbox calculates the inertial moment according to the Mass and shape size of the entry and exit.
THIS.BODY.P = CC.P (X, Y);
BODY.P can be used to define the centroid of a rigid body object.
Force or impulse can be applied to a rigid body by means of applyforce or applylmpulse.
Cocos2d-js Chipmunk Physics Engine related (1)