Time to take all of our Box2D knowledge and put it all together, to create the ultimate mix between Angry Birds and Crush the Castle.
First, we modify a little the
ground
function to let it create the ground in the same place as we created it during our latest Angry Birds prototype:private function ground():void { var bodyDef:b2BodyDef=new b2BodyDef(); bodyDef.position.Set(320/worldScale,465/worldScale); var polygonShape:b2PolygonShape=new b2PolygonShape(); polygonShape.SetAsBox(320/worldScale,10/worldScale); var fixtureDef:b2FixtureDef=new b2FixtureDef(); fixtureDef.shape=polygonShape; var groundBody:b2Body=world.CreateBody(bodyDef); groundBody.CreateFixture(fixtureDef); }
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...