MXPain Posted August 16, 2014 Share Posted August 16, 2014 Hi guys. How I can get Sprite object from bodyA or ShapeA ?collisionHandler: function (bodyA, bodyB, shapeA, shapeB, contactEquations) Link to comment Share on other sites More sharing options...
Dumtard Posted August 16, 2014 Share Posted August 16, 2014 bodyA.sprite Link to comment Share on other sites More sharing options...
MXPain Posted August 16, 2014 Author Share Posted August 16, 2014 And that's not so, and that's how;)bodyA.parent.sprite Link to comment Share on other sites More sharing options...
Dumtard Posted August 16, 2014 Share Posted August 16, 2014 I'm sorry I must have been mistaken on what type of object bodyA is, thought it was a p2 body. What type of object is it and what is parent? Link to comment Share on other sites More sharing options...
wayfinder Posted August 16, 2014 Share Posted August 16, 2014 It's a p2 body, but the phaser p2 body is not the same thing. The "real" p2 body is p2body.data Link to comment Share on other sites More sharing options...
Dumtard Posted August 16, 2014 Share Posted August 16, 2014 Interesting, if you add the contact function to the body instead of the p2 world it passes (body, shapeA, shapeB, equation) without the first body, but the body passed is a Phaser P2 Body not a P2 Body like in this example. Wonder why the difference. Link to comment Share on other sites More sharing options...
MXPain Posted August 16, 2014 Author Share Posted August 16, 2014 here's a little bit of my final code for example)game.physics.p2.onBeginContact.add(this.collisionHandler, this);collisionHandler: function (bodyA, bodyB, shapeA, shapeB, contactEquations) { if(shapeA.material==null || shapeB.material==null)return; if(shapeA.material.name=="port" && bodyB.parent.sprite.name.slice(0,5)=='enemy') { var spr = bodyB.parent.sprite; }} Link to comment Share on other sites More sharing options...
Recommended Posts