Tutorial: How to create a game like Angry Birds in Flash with Box2d- Part 2 – Create the world

Part 2 – Create the world with Box2D


Here the second tutorial to learn how to create a physic based game like Angry Birds in Flash.

You can download the complete sources here: How_to_create_a_game_like_angry_birds_part2.zip

If you missed the first tutorial you can find it here: https://benoitfreslon.com/fr/tutorial-how-to-create-a-game-like-angry-birds-with-box2d-world-construction-kit-flash-part-1

In this tutorial I will show you how to create an object like an indestructible metal board.
We will use this object in a simple level with a simple structure.

Stage modification

From the Properties pannel, modify the width of the stage to 800px.

Capture d’écran 2013-04-01 à 20.27.19

Floor creation

Let’s start to create the floor MovieClip.

Insert > New Symbol > Name: Floor > Type: MovieClip > Export for ActionScript > Class: Floor > Base Class: shapes.Box > OK

Capture d’écran 2013-04-01 à 21.12.18

Now draw a simple green square.

Capture d’écran 2013-04-01 à 20.31.51

NB: The World Construction Kit engine always uses the center of the object as a gravity center.

Always center the shape with the Align pannel:

Capture d’écran 2013-04-01 à 20.32.03

Now click on the “Scene 1” to go back on the main stage then double click on the World MovieClip to get inside.

You must construct your level into the World MoieClip only.

From your library drag and drop an instance of Floor in the stage:

Capture d’écran 2013-04-01 à 20.33.33

Then scale the floor box to make a beautiful floor with the Free tool transform from the toolbar on the left.

Delete the old grey floor and use the new one. Place the floor in the bottom like this:

Capture d’écran 2013-04-01 à 20.34.35

To set all physic parameters you have 2 solutions. By using ActionScript code (later) or using the Flash component properties.

Let’s define a Flash component on the Floor object.

From the library  > Select the Floor MovieClip > Right click > Define component

Capture d’écran 2013-04-01 à 20.39.14

Class: wck.BodyShape > OK.

Capture d’écran 2013-04-01 à 20.41.06

Now you can see the component properties if you click on the Floor instance in the stage. Look at the component parameters in the properties pannel.

Use this settings:

Capture d’écran 2013-04-01 à 20.44.23

Create a dynamic board

We will create an iron board.

Insert > New Symbol > Name: IronPlate > Type: MovieClip > Export for ActionScript > Class: IronPlate > Base class: shapes.Box > OK

Capture d’écran 2013-04-01 à 20.45.08

Draw a grey board: width:200px and height: 10px. Then center the shape like this:

Capture d’écran 2013-04-01 à 20.45.41

We will set the same settings to all boards in the game with only one class.

We this method you can win a lot of time and you don’t have to set one by one. Otherwise it’s pain in the ass.

That’s why we have to create the IronPlate class.

File > New > AcitonScript 3.0 Class > Class name: IronPlate > OK

Capture d’écran 2013-04-01 à 20.46.39

Then > File > Save as > IronPlate.as (in the same folder as the .fla folder).

Capture d’écran 2013-04-01 à 20.47.05

Copy and paste this code in the IronPlate.as file to define a generic behavior for all metal boards.

Finally add several IronPlate instances into the World MovieClip on the stage.

Build a simple structure like this to test the game. I reuse the grey box to destroy my test structure.

Capture d’écran 2013-04-01 à 20.54.20

Test the animation > CTRL + Enter

If you have several mistakes or if the boards are static check if IronPlates MovieClip are in the Wolrd MovieClip.

Scene > World > IronPlates

See you !

The vuvuzela game: just for fun

The Vuvuzelga game

The Vuvuzela game

After the hand of Thierry Henry the vuvuzela game.

PLAY HERE : https://benoitfreslon.com/my-games/the-vuvuzela-game/
Play on Facebook:  The vuvuzela game sur Facebook

Game made in 4 hours just for fun :).


Play the vuvuzela game. Blow up the Maradona’s head with your vuvuzela.

How to play:

Just click to “shoot”.

Emebed this game: