Game Development Reference
In-Depth Information
polygonShape.SetAsOrientedBox(armW,armH,armOrigin);
body.CreateFixture(fixtureDef);
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);
var armJoint:b2RevoluteJointDef;
armJoint=new b2RevoluteJointDef();
armJoint.bodyA=body;
armJoint.bodyB=arm;
armJoint.localAnchorA.Set(0,-115/worldScale);
armJoint.localAnchorB.Set(0,0);
armJoint.enableMotor=true;
armJoint.maxMotorTorque=1000;
armJoint.motorSpeed=6;
var siege:b2RevoluteJoint;
siege=world.CreateJoint(armJoint) as b2RevoluteJoint;
var projectileX:Number=(pX-80)/worldScale;
var projectileY:Number=(pY-115)/worldScale;
bodyDef.position.Set(projectileX,projectileY);
polygonShape.SetAsBox(5/worldScale,5/worldScale);
fixtureDef.shape=polygonShape;
fixtureDef.filter.categoryBits=0x0004;
fixtureDef.filter.maskBits=0x0004;
var projectile:b2Body=world.CreateBody(bodyDef);
projectile.CreateFixture(fixtureDef);
var slingJoint:b2DistanceJointDef;
slingJoint=new b2DistanceJointDef();
slingJoint.bodyA=arm;
slingJoint.bodyB=projectile;
slingJoint.localAnchorA.Set(-40/worldScale,0);
slingJoint.localAnchorB.Set(0,0);
slingJoint.length=40/worldScale;
sling=world.CreateJoint(slingJoint) as b2DistanceJoint;
}
var frontWheel:b2Body=addWheel(pX+20,pY+15);
var rearWheel:b2Body=addWheel(pX-20,pY+15);
var rJoint:b2RevoluteJointDef=new b2RevoluteJointDef();
rJoint.bodyA=body;
rJoint.bodyB=frontWheel;
 
Search WWH ::




Custom Search