플레이어가지면과 충돌하지 않는 이유는 무엇입니까? 필터를 잘못 사용 했습니까? 모든 상수를 상수라는 클래스에 저장합니다. 다음은 내가 사용하는 코드입니다.필터를 올바르게 사용하려면 어떻게해야합니까?
내 플레이어 정의 방법은 다음과 같습니다.
public void defineMainPlayer1() {
BodyDef bDef = new BodyDef();
bDef.position.set(128/Constants.PPM, 256/Constants.PPM);
bDef.type = BodyDef.BodyType.DynamicBody;
b2body = world.createBody(bDef);
PolygonShape shape = new PolygonShape();
shape.setAsBox(42/2/Constants.PPM, 94/2/Constants.PPM);
FixtureDef fDef = new FixtureDef();
fDef.shape = shape;
fDef.filter.categoryBits = Constants.PLAYER1_BIT; // Setting the filter
// for my Player
fDef.filter.maskBits = Constants.BRICK_BIT;
b2body.createFixture(fDef).setUserData(this);
EdgeShape head = new EdgeShape();
head.set(new Vector2(-30/Constants.PPM, 49/Constants.PPM),
new Vector2(30/Constants.PPM, 49/Constants.PPM));
fDef.shape = head;
fDef.isSensor = true;
b2body.createFixture(fDef).setUserData("head");
}
Constants.BRICK_BIT 및 Constants.BRICK_BIT의 정의를 표시 할 수 있습니까? – Aleris