kray Posted April 8, 2015 Share Posted April 8, 2015 Do functions take parameters implicitly? I need to check for overlap and kill a sprite if overlap is true. So far, this is my code: update: function() { this.physics.arcade.collide(player,ground); this.physics.arcade.collide(letters,ground); this.physics.arcade.overlap(player, letters, this.collectLetter, null, this); this.physics.arcade.overlap(letters, ground, this.killLetter, null, this);My functions are: collectLetter: function(player,letter) { letter.kill(); //increase score }, killLetter: function(letter,ground) { letter.kill(); }But this doesn't seem to be working. The sprite is not being killed in killLetter, when it overlaps with the ground. Although it is being killed in collectLetter, i.e, when a player overlaps with it. Link to comment Share on other sites More sharing options...
Akshar Patel Posted April 8, 2015 Share Posted April 8, 2015 Use only overlap. Don't use both overlap and collide. Link to comment Share on other sites More sharing options...
kray Posted April 8, 2015 Author Share Posted April 8, 2015 I have enabled physics, but it isn't working. On writingthis.physics.arcade.collide(letters,ground);there is no overlap and the letter is stopping above the ground. But if I don't give this statement, as soon as letter comes in contact with the ground, the ground falls down. Link to comment Share on other sites More sharing options...
kray Posted April 8, 2015 Author Share Posted April 8, 2015 When I changed ground to a group, it started working. Link to comment Share on other sites More sharing options...
Recommended Posts