Physics body contact point Cocos2d-x

  • sromic
    Likes 0

    Problem Description

    Hello,

    I am creating a dart throwing game where two line sprites (one horizontal covering the entire screen width, another vertical covering the entire screen height) forms a cross hair at their intersection point. The horizontal line moves from left to right and back while vertical line moves from up to down and back independently of each other.

    As shown in the cocos2d-x physics tutorial, I have both lines have rectangular physics bodies. I need to find the point of contact of the two lines at any given time. My thrown dart will land at that point. 

    However, when I use contact.getContactData()->points[0] through contact.getContactData()->points[3] inside the onContactBegin(cocos2d::PhysicsContact &contact), it gets me the right y position, but the x position is always at the left most point of the vertical line. 

    Please help. I need to solve this urgently, as I have a delivery of this game soon.

    Thank you,

    Sourav

  • Sonar Systems admin
    Likes 0

    How much to the left is it?

  • sromic
    Likes 0

    It is to the left end of the vertical line

  • Sonar Systems admin
    Likes 0

    By how many pixels, roughly?

Login to reply