box2d contact listener fixtures order

前端 未结 1 537
说谎
说谎 2021-01-16 17:56

I am trying to understand how does it work.

In my game I use box2d physics, to handle contacts I use contact listener, example:

ContactListener conta         


        
相关标签:
1条回答
  • 2021-01-16 18:45

    No, there is no guarantee which fixture is which. You have to check for both possibilities, like this:

    if ( (userdataA.equals("player") && userDataB.equals("ground")) ||
         (userdataA.equals("ground") && userDataB.equals("player")) )
             player.increaseFootContacts();
    
    0 讨论(0)
提交回复
热议问题