【问题标题】:cocos2d-x : setCatgoryBitmask not workingcocos2d-x : setCatgoryBitmask 不工作
【发布时间】:2018-06-03 15:45:26
【问题描述】:

由于某种原因,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

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

【问题讨论】:

    标签: cocos2d-x collision


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-09-12
      • 1970-01-01
      相关资源
      最近更新 更多