iforce2d . , box2d v2.2.1, cocos2D v2.0.0, Xcode v4.5.2 ( , b2Body "" , .. ):
b2Fixture *fix = body->GetFixtureList();
b2Filter filter = fix->GetFilterData();
filter.groupIndex = -1*kPlayerGroupIndex;
fix->SetFilterData(filter);
In the above code, I prevent the "body" from matching with the body of my player, which also has the same groupIndex value, that is -1 * kPlayerGroupIndex, where kPlayerGroupIndex is a positive integer constant. Any bodies with this negative index group never collide with each other. You can also update category bits or maskBits to prevent conflicts.
GetFilterData (& filter) and SetFilterData (& filter) return errors for me with the above version numbers.
source
share