Game Development Reference
In-Depth Information
rJoint.localAnchorA.Set(20/worldScale,15/worldScale);
rJoint.localAnchorB.Set(0,0);
if (motor) {
rJoint.enableMotor=true;
rJoint.maxMotorTorque=1000;
rJoint.motorSpeed=0;
frj=world.CreateJoint(rJoint) as b2RevoluteJoint;
}
else {
var rj:b2RevoluteJoint;
rj=world.CreateJoint(rJoint) as b2RevoluteJoint;
}
rJoint.bodyB=rearWheel;
rJoint.localAnchorA.Set(-20/worldScale,15/worldScale);
if (motor) {
rrj=world.CreateJoint(rJoint) as b2RevoluteJoint;
}
else {
rj=world.CreateJoint(rJoint) as b2RevoluteJoint;
}
return body;
}
Let's dissect it chunk by chunk:
var armOrigin:b2Vec2=new b2Vec2(0,-60/worldScale);
var armW:Number=5/worldScale
var armH:Number=60/worldScale
polygonShape.SetAsOrientedBox(armW,armH,armOrigin);
body.CreateFixture(fixtureDef);
These five lines create the vertical bar which goes from the trailer to the
morning star. The vertical bar is part of the trailer itself as its fixture has been
added to the same body. It's a compound object.
bodyDef.position.Set(pX/worldScale,(pY-115)/worldScale);
polygonShape.SetAsBox(40/worldScale,5/worldScale);
fixtureDef.shape=polygonShape;
fixtureDef.filter.categoryBits=0x0002;
fixtureDef.filter.maskBits=0x0002;
var arm:b2Body=world.CreateBody(bodyDef);
arm.CreateFixture(fixtureDef);
 
Search WWH ::




Custom Search