您的位置:首页 > 移动开发 > Cocos引擎

cocos2dx 3.0 box2D碰撞相关

2016-03-01 10:14 344 查看
关于box2D碰撞过程中三个函数在源代码

setCategoryBitmask(int bitmask)

setContactTestBitmask(int bitmask)

setCollisionBitmask(int bitmask)

源码:
// bitmask check
if ((shapeA->getCategoryBitmask() & shapeB->getContactTestBitmask()) == 0
|| (shapeA->getContactTestBitmask() & shapeB->getCategoryBitmask()) == 0)
{
contact.setNotificationEnable(false);
}

if (shapeA->getGroup() != 0 && shapeA->getGroup() == shapeB->getGroup())
{
ret = shapeA->getGroup() > 0;
}
else
{
if ((shapeA->getCategoryBitmask() & shapeB->getCollisionBitmask()) == 0
|| (shapeB->getCategoryBitmask() & shapeA->getCollisionBitmask()) == 0)
{
ret = false;
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: