I’m trying to integrate a game, built with matter-js, into my existing SvelteKit webapp but am getting stumped as to why gravity is not affecting the circle body I’m adding. The following is the typescript code within my svelte file:
onMount(async () => {
const Matter = await import('matter-js');
const canvas = document.getElementById("canvas")!
const engine = Matter.Engine.create();
const ball = Matter.Bodies.circle(100, 0, 10);
Matter.Composite.add(engine.world, ball);
Matter.Engine.update(engine);
const render = Matter.Render.create({
element: canvas,
engine: engine,
})
Matter.Render.run(render);
Matter.Runner.run(engine);
})
The ball is stuck in the initial position set within the circle() method. I’m using vite for the local dev server.