I'm trying to create a 'Bomber-man' like game using Phaser3 library. For this purpose I'd like to define a collision relationship between the player and the bricks, and more importantly - detect the collision direction relative the the player.
I've noticed body properties like touching or blocked but they are always set to false. (please see below)
//scene.js
// bricks static group
this.scene.physics.add.staticGroup({ immovable: true });
// player defined in external file (as sprite)
this.player = new Player(this, 90, 90)
// player.js
// ...
this.physics.add.collider(
this,
scene.bricks,
function(player, brick) {
if(player.body.touching.left) { //ALWAYS FALSE!!!
this.isBlockedFromLeft = true;
}, else if(player.body.touching.right) {
this.isBlockedFromRight = true; // ALWAYS FALSE!!!
}
},
null,
this
);
I'd appreciate any help. This is driving me crazy. Maybe there is a better way to do it and i'm missing something...
Thanks in advance.
else if(player.body.touching.rigt)
. It should beelse if(player.body.touching.right)
. Do you have a link to a repo or an online code playground? I'll take a look at it. – Manuel Abascalplayer.js
file & I can't find it! – Manuel Abascal