GetBodyCount()在Box2d中始终返回0吗? [英] GetBodyCount() always returning 0 in Box2d?

查看:99
本文介绍了GetBodyCount()在Box2d中始终返回0吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am using the cocos2d-iphone + Box2d engine, I have a simple call in Box2d to create a body:

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

然后我通过以下方式打印新增加的身体计数变量:

Then I am printing the newly incremented body count variable through:

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

但是, GetBodyCount()始终返回 0 ?我知道主体计数变量正在递增,因为当我调试并进入 CreateBody(..) m_BodyCount 时,递增,检查器将分别返回 1 。我不明白使用 world-> GetBodyCount()仅运行 return m_BodyCount 怎么会失败并返回0?

However, GetBodyCount() always returns 0? I know the body count variable is being incremented, as when I debug and step into CreateBody(..) m_BodyCount is incrementing, and my inspector returns 1 respectfully. I do not understand how with world->GetBodyCount() simply running a return m_BodyCount could this be failing and returning 0?

希望有人可以帮忙!
干杯。

Hope somebody can help! Cheers.

我正在使用SVN版本。 r31

I am using SVN rev. r31

Graham

推荐答案

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

Is GetBodyCount() returning an int? If so, you should use %d in the format string.

这篇关于GetBodyCount()在Box2d中始终返回0吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆