Game Development Reference
In-Depth Information
2.
Then, we need to update the Main function to include the custom listener, the
bricks, and the pigs.
public function Main() {
world=new b2World(new b2Vec2(0,5),true);
world.SetContactListener(new customContact());
debugDraw();
ground();
brick(402,431,140,36);
brick(544,431,140,36);
brick(342,396,16,32);
brick(604,396,16,32);
brick(416,347,16,130);
brick(532,347,16,130);
brick(474,273,132,16);
brick(474,257,32,16);
brick(445,199,16,130);
brick(503,199,16,130);
brick(474,125,58,16);
brick(474,100,32,32);
brick(474,67,16,32);
brick(474,404,64,16);
brick(450,363,16,64);
brick(498,363,16,64);
brick(474,322,64,16);
pig(474,232,16);
var frontCart:b2Body=addCart(200,430,true);
var rearCart:b2Body=addCart(100,430,false);
var dJoint:b2DistanceJointDef=new b2DistanceJointDef();
dJoint.bodyA=frontCart;
dJoint.bodyB=rearCart;
dJoint.localAnchorA=new b2Vec2(0,0);
dJoint.localAnchorB=new b2Vec2(0,0);
dJoint.length=100/worldScale;
var distanceJoint:b2DistanceJoint;
distanceJoint=world.CreateJoint(dJoint) as
b2DistanceJoint;
addEventListener(Event.ENTER_FRAME,updateWorld);
stage.addEventListener(KeyboardEvent.KEY_DOWN,
keyPressed);
stage.addEventListener(KeyboardEvent.KEY_UP,keyReleased);
}
 
Search WWH ::




Custom Search