I am new to matter.js and I am trying to detect a collision in a function but I cannot figure out how. this is all the relevant code.
ball = this.matter.add.sprite(400, 400, ‘ball’, null);
//creating the function to create the ground
function groundCreate (x, y, image, angle, name, place)
{
name = place.matter.add.sprite(x, y, image, null).setDisplaySize(200, 50).setAngle(angle).setStatic(true);
//tried to do collision detection here but failed :(
place.matter.world.on('collisionstart', (event)=> {
const bodyA = ball;
const bodyB = name;
bodyA.setDisplaySize(100, 100);
});
}
groundCreate(600, 500, ' ', 45, this.ground1, this);