Cocos2dx box2d details how to set the response force of an object

Source: Internet
Author: User

Cocos2dx box2d details how to set the response force of an object

Dionysoslai ([email protected]) 2014/7/29

In box2d, objects have three attributes:

1.DensityThe mass (that is, the density) of a unit volume means that an object with a higher density has more quality and is more difficult to move.

2.Friction, Friction, range: 0-1.0. 0 indicates that there is no friction. 1 indicates the maximum friction and almost no moving friction.

3.Restitution, Recovery force, ranging from 0 to 1.0. 0 means that the object will not rebound after the collision, 1 means that the collision is completely elastic and will rebound at the same speed.

 

Density and friction are easy to understand, because these two attributes are not closely related to other objects, while the recovery force is related to the mutual relationship between objects. This is becauseForce interaction. At the same time, because the force is the interaction principle, the force is equal to the reaction force.On the other hand, according to the test results, we can know that if two objects touch each other, if the response of object A is a, then the response of object B is B.If the reply power of the two is different, the reply power acting on the two is max (a, B). This conclusion is still true even if the reply power of one party on both sides is 0.

Based on the above, we can set up an elastic steel ball to have different elasticity on the left and right sides of the wall (the design of the egg is because of the planning requirements, I found the above conclusion ), you only need to set the reply force of the steel ball to 0, and the reply force of the left and right walls is different. Similarly, based on this design, we can designAdsorption Wall, Adsorbed the steel ball on the wall (a sensor may be required here, that is, the gravity is eliminated within the Wall range ).

Haha, That's it today. I haven't written a blog for a long time, really :~). I have been playing picture books recently. The design is really important for games !!!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.