Jump to content

Passing parameters to functions


kray
 Share

Recommended Posts

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

I have enabled physics, but it isn't working. 

On writing

this.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

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...