简体   繁体   中英

Cocos2d - Is is possible to turn off collision for a Box2d b2Body with a b2FixtureDef?

I have a b2Body with a b2FixtureDef. I'd like to be able to turn off the ability of the b2Body to collide. Is this possible?

Yes it is possible. Make it sensor.

    b2FixtureDef fd;
    fd.isSensor = true;
    body->CreateFixture(&fd);

Also with filter(fd.filter) you can specify collision specific to body.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM