Hey everybody.
I have asked two or three questions in this forum about Box2D and how to use it in cocos creator. My goal was to found out how I can use liquidfun library in cocos creator. I found that the name space is a little bit different in creator, so instead of b2World
I should use b2.World
. But still I have some problems using liquidfun. Here is the example that I’m trying to run:
var gravity = new b2Vec2(0, -10);
world = new b2World(gravity);
var bd = new b2BodyDef();
var ground = world.CreateBody(bd);
bd.type = b2_dynamicBody;
bd.allowSleep = false;
bd.position.Set(0, 1);
var body = world.CreateBody(bd);
var b1 = new b2PolygonShape();
b1.SetAsBoxXYCenterAngle(0.05, 1, new b2Vec2(1, 0), 0);
body.CreateFixtureFromShape(b1, 5);
I have changed it into:
var gravity = new b2.Vec2(0, -10);
var world = new b2.World(gravity);
var bd = new b2.BodyDef();
var ground = world.CreateBody(bd);
bd.type = b2._dynamicBody;
bd.allowSleep = false;
bd.position.Set(0, 1);
var body = world.CreateBody(bd);
var b1 = new b2.PolygonShape();
b1.SetAsBoxXYCenterAngle(0.05, 1, new b2.Vec2(1, 0), 0);
body.CreateFixtureFromShape(b1, 5);
But I get this error:
Uncaught TypeError: b1.SetAsBoxXYCenterAngle is not a function
I changed SetAsBoxXYCenterAngle
to SetAsBox
then I got this error:
Uncaught TypeError: body.CreateFixtureFromShape is not a function
As you can see here CreateFixtureFromShape
is a function in Box2D.
Am I doing something wrong or cocos creator does not support Box2D completely?