質問

Sorry if there is another thread like this one, but i cannot find a solution..

I have a box2d game and i need to make one body to collide ONLY with the player and nothing else. Can you help me? How to define the mask bits, or the groups?

役に立ちましたか?

解決

I found a solution (i write on LibGDX). I use setContactFilter(). I implemented this interface and override shoudCollide()

public class BackgroundContactFilter implements ContactFilter {
 @Override
 public boolean shouldCollide(Fixture fixtureA, Fixture fixtureB){
  return false;
 }

}

All interactions are disabled with this code.

I hope that this would be helpful to someone.

他のヒント

Heres a great article that will walk you through everything you need to know about masks and groups:

http://www.aurelienribon.com/blog/2011/07/box2d-tutorial-collision-filtering/

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top