문제

Hi, I am developing a car game. In it I have a player's car and an enemies car. What I want to do is, at some specific time the player's car should not collide with the enemies car. For this purpose, I want to update the maskbit of player's car at runtime. I have made custom sprite class and used this line of code to do so

mPhysicsWr.getPhysicsConnectorManager()
          .findBodyByShape(this)
          .getFixtureList()
          .get(0)
          .getFilterData()
          .maskBits=0;

but it still is not updating the maskbit of the body of this sprite. Any idea..? Thank you.

도움이 되었습니까?

해결책

You're going to need to assign the filter data again using:

Filter filter = new Filter();
filter.maskBits = yourMaskBits;         mPhysicsWr.getPhysicsConnectorManager().findBodyByShape(this).getFixtureList().get(0).setFilterData(filter);

For pretty much every Get method in Box2D there is a corresponding Set method. Its pretty unusual in the API to set properties directly. Most of the time you will use getters and setters.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top