Before we start the movement of the platforms, we need to activate physics in the projects.
To do this, first let’s install the npm package with the MatterJS physical library:
npm i matter-js
Let’s activate the engine in App.js. To do this, follow 3 steps:
- engine initialization
- creating a runner
- running the engine
import * as Matter from 'matter-js';
// ...
class Application {
run(config) {
// ...
this.createPhysics();
}
createPhysics() {
this.physics = Matter.Engine.create();
const runner = Matter.Runner.create();
Matter.Runner.run(runner, this.physics);
}
// ...
}