代码之家  ›  专栏  ›  技术社区  ›  GONeale

getBodyCount()总是在box2d中返回0?

  •  1
  • GONeale  · 技术社区  · 15 年前

    我正在使用cocos2d iphone+box2d引擎,我在box2d中有一个简单的调用来创建主体:

    b2Body *crateBody = world->CreateBody(&crateBodyDef);
    

    然后,我将通过以下方式打印新增加的body count变量:

    CCLOG(@"There are %0.0f bodies in the world.", world->GetBodyCount());
    

    然而, GetBodyCount() 总是返回 0 ?我知道body count变量正在增加,就像我调试和单步执行时一样。 CreateBody(..) m_BodyCount 正在递增,我的检查器返回 1 恭敬地我不明白怎么用 world->GetBodyCount() 只需运行 return m_BodyCount 这会失败并返回0吗?

    希望有人能帮忙! 干杯。

    我正在使用SVN版本。R31

    格雷厄姆

    1 回复  |  直到 15 年前
        1
  •  3
  •   gerry3    15 年前

    GetBodyCount() 返回int?如果是这样,您应该在格式字符串中使用%d。

    推荐文章