Jump to content

Get Sprite from BodyA


MXPain
 Share

Recommended Posts

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

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

 Share

  • Recently Browsing   0 members

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