this.physics.world.setBounds(0, 0, config.width, config.height);
this.physics.world.on(‘worldbounds’, onWorldBounds);
let player = this.physics.add.image(200,100,'a');
player.setDamping(true);
player.setDrag(0.99);
player.setMaxVelocity(100);
player.setCollideWorldBounds(true);
player.body.onWorldBounds = true;
let enemys = this.physics.add.group();
function onWorldBounds (body, blockedUp, blockedDown, blockedLeft, blockedRight){
if(blockedUp){ //If ball move out of screen
//
body.alpha = 0.5;
}
console.log('fff')
}
onWorldBounds are called 20 times every second even player are not collision with bounds.
If player collision with bounds, it’s not even detected.
How to fix this?
Thanks