cocos Creator how to use the physics engine

1: Open three steps and a physics engine pit:

(1) open Engine: cc.director.getPhysicsManager () enabled = true.

(2) Configuration Gravity:. Cc.director.getPhysicsManager () gravity = this.gravity

(3) controlled by debug mode switch is turned on:

 

 Open physics engine script code, which must be written onLoad function, or can not open, remember, remember;

2: Editing physical shape and physical node

(1) a node is created, as a carrier;

(2) adding component instance a rigid body, the rigid type configuration, static, dynamic;

(3) adding a physical shape to the object, i.e. Collider, called impactor;

  Support impactor rectangular, circular, polygonal, any shape can do it. A node can have multiple shapes.

 

 

 

3: Collision Detection

  Collision detection is the physics engine which was commonly used functions, in fact, very simple, that node to obtain inspection car collision, as long as the node, hanging script instance, and then reload the physical collision monitoring function can be obtained,

onBeginContact/ onEndContact/ onPreSolve/ onPostSolve
4: Collision relationship Configuration
Each node has a group, you can add a group, and to specify the type of node.

Click Edit:

Here there will be a collision pairing relationship, the relationship between the collision was configured correctly, you can happily get used. If you do not, you can add the group 705,182,843, was to get complete video tutorials.

Guess you like

Origin www.cnblogs.com/blakehuangdong/p/11329740.html