GetBodyCount() always returning 0 in Box2d?

本秂侑毒 提交于 2019-12-11 10:35:32

问题


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());

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.

I am using SVN rev. r31

Graham


回答1:


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



来源:https://stackoverflow.com/questions/2116497/getbodycount-always-returning-0-in-box2d

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!