Phorey Posted December 2, 2017 Share Posted December 2, 2017 Hi all, I'm trying to detect player to tile overlapping: // Set player spike collision detection game.map.setTileIndexCallback(SPIKE_ID, function () { playerDeath(game); }, game, game.worldLayer); It works great, but the problem I'm running into is that if a sprite other than the player's sprite runs into the spike tile, the playerDeath function is called. Is there a way to check if it's the player sprite overlapping with the tile before calling the playerDeath function? I've tried making the spikes tile separate and hoped this would work: function updateSpikeCollision(game) { game.physics.arcade.overlap(game.player, game.spikeLayer, function(player, spike) { console.log("overlapping"); }, null, game); }, But this callback gets triggered regardless of overlapping. Any pointers would be appreciated! Thanks Link to comment Share on other sites More sharing options...
samme Posted December 3, 2017 Share Posted December 3, 2017 If you use setTileIndexCallback you should be able to examine the sprite (first argument) in the callback. If you use arcade.overlap, see the Tilemaps notes in Arcade#overlap. Blank tiles also trigger overlap so you need to test the tile ID. Phorey 1 Link to comment Share on other sites More sharing options...
Recommended Posts