Hello,
I’m trying to detect collision between world and image and this is the code:
create() {
var image = this.physics.add.image(posx, posy, 'key')
.setInteractive({ draggable: true })
.on('drag', function (pointer, dragX, dragY) {
this.y =dragY;
});
this.physics.add.existing(image)
this.physics.world.setBounds(0, 0, width, height);
image.setCollideWorldBounds(true);
image.onWorldBounds = true;
this.physics.world.on('worldbounds', function(body){
console.log('hello from the edge of the world', body);
},this);
}
In the above code when image is dragged to the bounds it does collide but the log is not displayed.
I’m not sure what the mistake is so I need help with this