Jump to content

Detect collision with world bounds?


soggybag
 Share

Recommended Posts

I want o detect a collision with the world bounds. I'd also like to know which edge the collision made contact with. 

I used this to setup collisions. 

this.ball.body.collideWorldBounds = true;

I was trying:

this.physics.collide(this.ball, this.worldBounds, () => { console.log('word!') }, null, this); 

To be honest I was just guessing. It doesn't work. 

 

Link to comment
Share on other sites

I go this working with

this.physics.world.on('worldbounds', this.onWorldBounds, this)

I'm not sure why this doesn't work: 

this.physics.collide(this.ball, this.physics.world, () => {
	console.log('Hit world')
}, null, this)

Obviously I'm missing something. The last example does work for bodies. But doesn't work for world. 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...