1: 3 steps and a hole to turn on the physics engine:
(1) Turn on the engine: cc.director.getPhysicsManager().enabled = true
(2) Configure gravity: cc.director.getPhysicsManager().gravity = this.gravity
p>
(3) Use the switch to control whether to turn on the debugging mode:
The script code for opening the physics engine must be written in the onLoad function, otherwise it cannot be opened, remember, remember;
p>
2: Edit physical nodes and physical shapes
(1) Create a node , As a carrier;
(2) add a rigid body component instance, configure the type of rigid body, static, dynamic;
(3) to Add a physical shape to the object, which is Collider, also called collider;
It supports rectangular collider, circle, polygon, and can be made into any shape. A node can have multiple shapes.
p>
3: collision detection
strong>Collision detection is a commonly used function in the physics engine, but it is actually very simple. To get the collision detection car for that node, just hang a script instance on the node, and then reload the physical collision detection function. strong>