문제

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