开发者

Xcode: Cocos2d: Can't create world with Box2D

My project originated 开发者_如何学Goas the cocos2d Box2D template and I'm having issues as soon as I tried to create a world:

world = new b2World(gravity,doSleep);

Gives the error: No matching constructor for initialization of 'b2World'.

The file is .mm, I assume it's some issue about library linking maybe? If so I'm using xCode 4, how can I check the lib is properly linked?

Thanks.


You are using Box2D v2.2 or newer. The b2World constructor no longer takes two arguments, just one (gravity). You have to set doSleep separately:

world = new b2World(gravity);
world->SetAllowSleeping(doSleep);

This won't be the only change you'll need to make to transition from Box2D v2.1.x to v2.2.x. Kobold2D has a working Box2D 2.2.1 sample project, even if you don't use Kobold2D you can get updated source code for Box2D basics. In particular the GLESDebugDraw class and how to setup a screen bounding box with a body using multiple shapes.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜