Hi all,
Pulling my hair out on this one. In the code below, everything works (renders as expected, collision works) fine.
Except for one thing: the two lines (one commented) that create the overlap object seem interchangeable. Swapping the first two arguments does not appear to change the order in which they are received by the process function. Either way, the player (that phaser dude in a sprite) comes in first (observed by the type being sprite and the key of the texture).
I must be doing something elementary wrong, but it escapes me… One could say “use it the way it works” but that feels downright wrong. Anyone any idea?
Thanks in advance,
Manno
dude = this.physics.add.sprite(100, 100, "dude");
var map = this.make.tilemap({
key: "map",
tileWidth: 64,
tileHeight: 64,
width: 16,
height: 8,
});
var tileset = map.addTilesetImage("tileset");
var platforms = map.createStaticLayer("baselayer", tileset, 0, 0);
var trapLayer = map.createStaticLayer("death", tileset, 0, 0);
platforms.setCollisionByProperty({collidable: true});
trapLayer.setCollisionByProperty({damage: true});
this.physics.add.collider(dude, platforms);
// this.physics.add.overlap(dude, trapLayer, doDamage, process, this);
this.physics.add.overlap(trapLayer, dude, doDamage, process, this);
}
function process(player, tile){
return tile.properties.damage;
}
function doDamage(player, tile){
console.log(player);
}