P2. JS Touch Material (contactmaterial) memo

Source: Internet
Author: User

Key code:
1Boxshape.material =NewP2. Material ();2Platformshape.material =NewP2. Material ();3 4 varMaterial =NewP2. Contactmaterial (boxshape.material, platformshape.material, {5Surfacevelocity:-50,6restitution:0.5,7friction:0.3,8Stiffness:1e79 });TenWorld.addcontactmaterial (material);
This component is needed for a common bounce effect. The effect of this code is that the block is free falling to the bezel, has a slight rebound effect, and has a right speed. According to the results of my experiment, whether it is Boxshape or Platformshape as Bodya, when Surfacevelocity is less than 0 o'clock, the block moves to the right, greater than 0 o'clock, naturally to the left. Restitution is the Bounce Force property, the default value is 1. Friction is the frictional force, the default value is 0.3. Stiffness is a stiffness attribute with a default value of 1e7. This contactmaterial class, there are other properties, but did not try out the effect, did not write to the example, is: Relaxation,relaxation of the resulting contactequation that Contactmaterial Generate
Frictionstiffness,stiffness of the resulting frictionequation that this contactmaterial generate
Frictionrelaxation,relaxation of the resulting frictionequation that this contactmaterial generate
Contactskinsize,offset to is set on contactequations. A positive value would make the bodies penetrate to all other. Can is useful in scenes where contacts need to is more persistent, for example when stacking. Aka "cure for Nervous Contacts". Really do not know how to translate, just paste it up as a memo. Practice Source Address: https://gist.github.com/yxzblue/3a66babfb93b889f0833#file-contactmaterial-html p2.js v0.6.0 package, Link: http ://pan.baidu.com/s/1mgsw7xa Password: Bj85p2.js's github address: https://github.com/schteppe/p2.js

P2. JS Touch Material (contactmaterial) memo

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.