Disabling gravity in Matter.js

2019-04-04 05:06发布

问题:

Is there any way to disable gravity in Matter.js? I want my objects (bodies) to keep their physical abilities (like reaction to collision, restitution, friction etc), but I'd like to prevent the reaction to device's gyro and orientation change.

回答1:

Try

engine.world.gravity.y = 0;

where engine is your engine instance.