cocos2d-x:setCatgoryBitmask不工作

cocos2d-x:setCatgoryBitmask不工作,cocos2d-x,collision,Cocos2d X,Collision,由于某些原因,cocos2d-x中PhysicsBody的函数setBatgoryBitmask()无效: OutputDebugStringA("Wall cat bitmask : "); OutputDebugStringA(std::to_string(body->getCategoryBitmask()).c_str()); OutputDebugStringA("\n"); body->setCategoryBitmask(2);

由于某些原因,cocos2d-x中
PhysicsBody
的函数
setBatgoryBitmask()
无效:

    OutputDebugStringA("Wall cat bitmask : ");
    OutputDebugStringA(std::to_string(body->getCategoryBitmask()).c_str());
    OutputDebugStringA("\n");
    body->setCategoryBitmask(2);
    OutputDebugStringA("Wall cat bitmask : ");
    OutputDebugStringA(std::to_string(body->getCategoryBitmask()).c_str());
    OutputDebugStringA("\n");
    body->addShape(PhysicsShapeEdgeBox::create(Size(dest - or ), mat, borderW));
    OutputDebugStringA("Wall cat bitmask : ");
    OutputDebugStringA(std::to_string(body->getCategoryBitmask()).c_str());
    OutputDebugStringA("\n");
结果:

Wall cat bitmask : -1
Wall cat bitmask : -1
Wall cat bitmask : -1

因此,我无法定义什么与什么冲突。
setCategoryBitmask
getCategoryBitmask
似乎都是简单的setter和getter,但我不知道这里发生了什么。

好吧,这太愚蠢了。如果您的身体还没有形状,则似乎无法设置类别或碰撞位掩码。在添加第一个形状后设置这些形状似乎可以解决问题