Jump to content

calling a function


peteblank
 Share

Recommended Posts

I'd like to create a function and be able to call it in another function. 

this one specifically 

   function coins(coin)
    {
        coin.setBounce(1);
                coin.body.setGravityY(300);
                this.physics.add.collider(coin, platforms);
                this.physics.add.collider(player, coin, collectCoin, null, this);
                coin.setVelocityX(60);  
                coin.setVelocityY(-300);
                coin.setCollideWorldBounds(true);
    }

That way every time the coin is created I can call the function for the coin's physics. 

Link to comment
Share on other sites

Well never mind. I'll just copy and paste it every time I create the coin no biggie. 

I've come across another problem though. 

I want to use the checkDown(key,[,duration]) method

I'm tying to make it so my character waits before it punches every time I press the shift key.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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