Jump to content

Detect falling hero and collect points if moving up


simeon_stoykov
 Share

Recommended Posts

Hello. I am new at Phaser and i am now developing simple JavaScript game. Here is the code. I want to implement die function when the hero fall to the ground from some distance (600px for example). Can someone help me with this because i searched for functions like this in phaser but i didn't manage to find something like that. The other question is how to make points system (collect points if the hero moves up on the platforms and loose the points he earned if he drop down on lower platform?

Link to comment
Share on other sites

 

You could check the sprite's velocity when it collides with an object.

 

You will have to custom code it though...

if(yourSprite.body.velocity >= 600 ){  die();}function die(){    console.log("you fell too fast and died.");}

Thanks but where to put that code and how to check if the player collides with the ground. I tried to put the code in the update function and tried if (this.player.body.touching.down) {put the code here} but it didn't work.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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