Rose Game Solutions Posted January 9, 2019 Share Posted January 9, 2019 How do you add collision detection in matter physics, especially world bounds collision? Link to comment Share on other sites More sharing options...
Rose Game Solutions Posted January 9, 2019 Author Share Posted January 9, 2019 I included phaser-matter-collision-plugin npm package info for matter-collision: https://www.npmjs.com/package/phaser-matter-collision-plugin Then, in my scene, I passed an array containing all the walls of the world bounds... like so: // 'this' refers to Phaser.Scene const { bottom, left, top, right } = this.matter.world.walls; this.matterCollision.addOnCollideStart({ objectA: [bottom, left, right, top], //world bounds objectB: this.gate, // some object to detect collision with callback: eventData => { // run logic here console.log(eventData) }, }); Link to comment Share on other sites More sharing options...
Recommended Posts