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

Matter.js: Adding a Bounce Property on Objects

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

也许您正在寻找 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: