predator Posted January 8, 2017 Share Posted January 8, 2017 When two sprites are overlapped, they call this function. killEnemy: function(player, enemy) { if (enemy.body.touching.up) { enemy.kill(); } else { return false; } } However, even if the enemy is not being touched on the top, as soon as there is an overlap, the enemy is killed. Why does this happen? Link to comment Share on other sites More sharing options...
PhasedEvolution Posted January 8, 2017 Share Posted January 8, 2017 strange. how is your overlap function ? Link to comment Share on other sites More sharing options...
predator Posted January 8, 2017 Author Share Posted January 8, 2017 The overlap function is this.physics.arcade.overlap(this.player, this.enemies, this.killEnemy); The enemy is in a group called enemies. I think I worded the question wrong, the problem is in the this.enemy.body.touching.up part of the code. In the console, I set it up to print the value, and when the player is touching it, it goes 'false' then 'true' twice, like 'false true true false true true false true true' et cetera. Link to comment Share on other sites More sharing options...
samme Posted January 9, 2017 Share Posted January 9, 2017 Can you try with just 1 enemy sprite in the game? Link to comment Share on other sites More sharing options...
predator Posted January 9, 2017 Author Share Posted January 9, 2017 But... There is only one enemy sprite Link to comment Share on other sites More sharing options...
samme Posted January 9, 2017 Share Posted January 9, 2017 Can you post the whole code or a working example? After `enemy.kill()` the sprite should be skipped by `arcade.overlap`. Link to comment Share on other sites More sharing options...
Recommended Posts