Search code examples
cocos2d-iphonebox2d-iphone

Porting Cocos2d 1.0 to Cocos2d 2.0


I got one old game and I tied to update Cocos2d 2.0 SDK. I got some compilation error.

b2Vec2 gravity;
gravity.Set(0.0f, -10.0f);
self.world = new b2World(gravity, true);

Error: No matching constructor for initialization of 'b2World'

When I change this to below code then works but Box2D debug shapes are not drawn.

self.world = new b2World(gravity);

How to initialize Box2d world in right way that show debug shapes?


Solution

  • Replace the GLESDebugDraw files with those found in a newly created cocos2d 2.0 + Box2D project. Your version is still using GL ES 1.1 commands which don't work in cocos2d 2.x