PeterBuju Posted May 11, 2016 Share Posted May 11, 2016 Hello Phaser people, I'm currently working on a game where the player flies around and gets damaged by touching obstacles. What I want to do is damage the player according to the speed that the player crashed into the obstacle with. I see that the restitution (bounce) effect moves the player in the opposite direction according to the "impact". Is there any way I could get hold of this "impact" value and use it to deal a certain damage to my player ? Best regards Link to comment Share on other sites More sharing options...
drhayes Posted May 11, 2016 Share Posted May 11, 2016 If you're using Arcade physics, I'm *pretty* sure you want the "sprite.body.overlapX" and "sprite.body.overlapY" properties. I *think* they're set by the time your collision handler runs, not sure how long the value stick around after that though. Link to comment Share on other sites More sharing options...
VitaZheltyakov Posted May 11, 2016 Share Posted May 11, 2016 Look: http://phaser.io/examples/v2/arcade-physics/custom-sprite-vs-group Use: collisionHandler Link to comment Share on other sites More sharing options...
PeterBuju Posted May 12, 2016 Author Share Posted May 12, 2016 Thanks for the replies guys ! My mistake was that I didn't mention that I am using p2 physics collision, hence using the "restitution" term. The collision is implemented according to this example: http://phaser.io/examples/v2/p2-physics/collision-groups Link to comment Share on other sites More sharing options...
Recommended Posts