Game Development Reference
In-Depth Information
7.
The levelFailed function just handles some kind of game over screen,
removing the click listener so the player cannot destroy bricks anymore,
setting the gameOver variable to true and displaying a game over text.
private function levelFailed():void {
textMon.text="Oh no, poor idol!!!";
stage.removeEventListener
(MouseEvent.CLICK,destroyBrick);
gameOver=true;
}
8.
Test the game, make the idol fall on the ground, and the game is over:
This was quite easy as there was only one collision to care about. What about the
Angry Birds game where there are pigs to kill and bricks to destroy?
Destroying bricks and killing pigs in
Angry Birds
Take the last example of Chapter 4 , Applying Forces to Bodies , the one with the working
sling, and let's start working on it.
1.
First, as usual, let's add some custom data to bricks, giving them a name in
the brick function:
private function brick(pX:int,pY:int,w:Number,h:Number):void {
var bodyDef:b2BodyDef=new b2BodyDef();
bodyDef.position.Set(pX/worldScale,pY/worldScale);
 
Search WWH ::




Custom Search