admin管理员组文章数量:1201604
I am looking at using Matter.js, a javascript physics engine, to have a bouncy ball in a simple game. It appears on their API that Matter might not have a property to change the bounciness of an object. Does anyone have any idea how I might go about implementing this?
I am looking at using Matter.js, a javascript physics engine, to have a bouncy ball in a simple game. It appears on their API that Matter might not have a property to change the bounciness of an object. Does anyone have any idea how I might go about implementing this?
Share Improve this question edited Apr 2, 2022 at 3:01 ggorlen 56.9k8 gold badges110 silver badges150 bronze badges asked Mar 18, 2015 at 22:28 mattericksonmatterickson 851 silver badge6 bronze badges 1 |1 Answer
Reset to default 29Maybe you're looking for restitution
?
https://brm.io/matter-js/docs/classes/Body.html#property_restitution
A Number that defines the restitution (elasticity) of the body. The value is always positive and is in the range (0, 1). A value of 0 means collisions may be perfectly inelastic and no bouncing may occur. A value of 0.8 means the body may bounce back with approximately 80% of its kinetic energy. Note that collision response is based on pairs of bodies, and that restitution values are combined with the following formula:
本文标签: javascriptMatterjs Adding a Bounce Property on ObjectsStack Overflow
版权声明:本文标题:javascript - Matter.js: Adding a Bounce Property on Objects - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738548516a2096902.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
restitution
property? – bvaughn Commented Mar 18, 2015 at 22:30