物理引擎碰撞过滤掩码设置的问题

auto body = PhysicsBody::createCircle(size.width/4);
    body->setContactTestBitmask(0x0001); 
    body->setCollisionBitmask(0x0001);
    body->setCategoryBitmask(0x0001);

    auto body1 = PhysicsBody::createCircle(size.width/4);
    body1->setContactTestBitmask(0x0001); 
    body1->setCollisionBitmask(0x0001);
    body->setCategoryBitmask(0x0001);


```


如上所示的两个刚体不是应该既碰撞也响应回调函数的吗?
可结果却是响应了回调函数却没有碰撞效果。。。
求大神解惑啊。。。。

这样子却是会碰撞却没响应回调函数

auto body = PhysicsBody::createCircle(size.width/4);
    body->setContactTestBitmask(0x0001); 
    body->setCollisionBitmask(0x0001);
    body->setCategoryBitmask(0x0001);

    auto body1 = PhysicsBody::createCircle(size.width/4);
    body1->setContactTestBitmask(0x0010); 
    body1->setCollisionBitmask(0x0001);
    body->setCategoryBitmask(0x0001);


```

你代码发全一点,第二个正常。应为要发生碰撞,条件是:
两者的类型掩码与对方的碰撞掩码相与,不为零则触发。必须互相相与都通过才行。
要发生回调函数响应也同样。。。

第二个例子body1的 ContactTestBitmask与 body相与为零,则无法处罚回调。。。

至于第一例子为何触发不了,,,你代码发来我看下。

void Game::createPlayer(){
        Sprite * playertouch = Sprite::create("image/di.png");
    playertouch->setPosition(240,100);
    playertouch->setScale(0.7);
    player_layer->addChild(playertouch);


    ArmatureDataManager::getInstance()->addArmatureFileInfo("Export/player/player.ExportJson");

    player = Armature::create("player");
    player->setPosition(ccp(240,300));
    player->setScale(0.5);
    player->getAnimation()->play("act");
    player_layer->addChild(player);

Size size = playertouch->getContentSize();    

    auto body = PhysicsBody::createCircle(size.width/4);
    body->setContactTestBitmask(0x0001); 
    body->setCollisionBitmask(0x0001);
    body->setCategoryBitmask(0x0001);

    auto body1 = PhysicsBody::createCircle(size.width/4);
    body1->setContactTestBitmask(0x0001); 
    body1->setCollisionBitmask(0x0001);
    body->setCategoryBitmask(0x0001)

playertouch->setPhysicsBody(body);

player->setPhysicsBody(body1);

}

void Game::onTouchMoved(Touch * touch, Event * event) {
    //玩家位置
    Point pos = playertouch->getPosition();
    //移动的距离
    Point jul = touch->getDelta(); 
    //目标位置
    Point movepos = pos+touch->getDelta(); 
    //移动到指定位置
    if(movepos.x >= 50 && movepos.x <= 430 && movepos.y <= 750 )
    {    
        playertouch->setPosition(movepos);        
    }
}

```


就这么两个函数,第一个创建,第二个移动,playertouch是随鼠标移动那个,player 是不动的那个

我也遇到这么个问题,纠结好久了,楼主弄明白了:6: 教下我呀:6:

解决了没?

来自2年后的请教,解决没

改用box2d了 内置的那个物理引擎不好用