gpt4 book ai didi

javascript - Matter.js:在对象上添加反弹属性

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:49:43 25 4
gpt4 key购买 nike

我正在考虑使用 Matter.js,一种 javascript 物理引擎,在一个简单的游戏中制作一个弹力球。在他们的 API 上显示,Matter 可能没有改变对象弹性的属性。有谁知道我可以如何实现它?

最佳答案

也许您正在寻找赔偿

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:

关于javascript - Matter.js:在对象上添加反弹属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29133903/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com