simeon_stoykov Posted March 27, 2015 Share Posted March 27, 2015 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 More sharing options...
markergreen Posted March 27, 2015 Share Posted March 27, 2015 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.");} Link to comment Share on other sites More sharing options...
simeon_stoykov Posted March 27, 2015 Author Share Posted March 27, 2015 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 More sharing options...
Recommended Posts