Box2D questions

Hi,

I’m starting with Box2D. I saw the sample in http://www.cocos2d-x.org/wiki/Box2D.

I tried to get the sample working but I have some doubts:

For example I can use:

b2PolygonShape floorShape;
floorShape.SetAsBox(w/ SCALE_RATIO,h/ SCALE_RATIO);

but I can’t use:

SetAsEdge 
instead of
SetAsBox

In the world constructor I can do this:

_world = new b2World(gravity); 

But I can’t do this:

_world = new b2World(gravity, doSleep); 

And more things like that.

So my question is, do I have a reduced version of Box2D? do I have to rewrite the Box2D library in order to have all the methods, etc? or is it an outdated code (the sample) and I can use similar methods provided by Box2D in order to get the expected result but using it in a different way?

Greetings!

It’s not a reduced version, just a different one, a newer one since you can’t do SetAsEdge. SetAsEdge was removed in version 2.1.2. After this version a special shape type named b2EdgeShape was added. You can use it like this:

b2EdgeShape edgeShape;
edgeShape.Set( b2Vec2(-15,0), b2Vec2(15,0) );
  
myFixtureDef.shape = &edgeShape;

Thanks, I understand.

I’m just trying to port the sample of the wiki from cocos2dx 2.x to 3.10 version… it looks like it will be harder than I expected :slight_smile: