There are a lot of nice info about Box2d that are quite very helpful but most of it is written in C. My knowledge of C is quite basic and thus i don't understand everything when i try to convert a code from C into Javascript.
Here's an example from box2d manual part 2.2:
code in C:
this is how i wrote it in javascript:
Here's an example from box2d manual part 2.2:
code in C:
Code:
b2BodyDef goundBodyDef;
groundBodyDef.position.Set(0.0, -10.0);
b2Body* groundBody = world.CreateBody(&groundBodyDef);//that's the line i don't understand. What is * after b2Body how do i write this line in Javascript?
b2PolygonShape groundBox;
groundBox.SetAsBox(50.0, 10.0);
groundBody->CreateFixture(&groundBox, 0.0);//that's the last line i don't understand. What is this arrow -> and how do i write this line in Javascript?
groundBodyDef.position.Set(0.0, -10.0);
b2Body* groundBody = world.CreateBody(&groundBodyDef);//that's the line i don't understand. What is * after b2Body how do i write this line in Javascript?
b2PolygonShape groundBox;
groundBox.SetAsBox(50.0, 10.0);
groundBody->CreateFixture(&groundBox, 0.0);//that's the last line i don't understand. What is this arrow -> and how do i write this line in Javascript?
this is how i wrote it in javascript:
Code:
var groundBodyDef = new b2BodyDef();
groundBodyDef.position.Set(0.0, -10.0);
//the 1st line of code in question
var groundBox = new b2PolygonShape();
groundBox.SetAsBox(50.0, 10.0);
//the 2nd line of code in question
groundBodyDef.position.Set(0.0, -10.0);
//the 1st line of code in question
var groundBox = new b2PolygonShape();
groundBox.SetAsBox(50.0, 10.0);
//the 2nd line of code in question