I started messing about with processing.js recently which has led me to messing with full blown processing (due to processing.js having no ide!) and I’m trying to apply physics to a basic game engine I’m putting together, to help me get my head around the language in general.
Anyway, back to the point; I’m using pBox2d which is a port of jBox2d which is in turn a java port of the original c++ Box2d physics engine! I had trouble trying to apply forces to move my little space ships- according to everything i had read online you use ApplyForce(b2Vec2 force, b2Vec2 point) but the b2Vec2 class doesn’t seem to exist- turns out you have to use Vec2 with jbox2d, and the method starts with a lower case a on this port to fall in to line with java conventions (that stumped me for bit!)
I dug out the full definition for the body class from jBox2d so for your reference, all the method signatures…
jBox2d: Body public Body(BodyDef bd, World world) //ctor public Vec2 getOriginPosition() public Vec2 getCenterPosition() public float getRotation() public Mat22 getRotationMatrix() public void setLinearVelocity(Vec2 v) public Vec2 getLinearVelocity() public void setAngularVelocity(float w) public float getAngularVelocity() public void applyForce(Vec2 force, Vec2 point) public void applyTorque(float torque) public void applyImpulse(Vec2 impulse, Vec2 point) public float getMass() public float getInertia() public Vec2 getWorldPoint(Vec2 localPoint) public Vec2 getWorldVector(Vec2 localVector) public Vec2 getLocalPoint(Vec2 worldPoint) public Vec2 getLocalVector(Vec2 worldVector) public boolean isStatic() public boolean isFrozen() public boolean isSleeping() public void allowSleeping(boolean flag) public Shape getShapeList() public ContactNode getContactList() public JointNode getJointList() public Body getNext() public Object getUserData() public void destructor() public void setOriginPosition(Vec2 position, float rotation) public void setCenterPosition(Vec2 position, float rotation) void synchronizeShapes() public void quickSyncShapes() public void freeze() public void wakeUp() public boolean isConnected(Body other)