Create a Flash prototype of The Moops – Combos of Joy – Step 2

Here we are with the 2nd part of the tutorial to create a game like The Moops. The guys at Heavy Boat, the studio behind the game, are following the tutorial too, so I hope I’ll try to make something really similar to their game.

In the first part I showed you how to fire the ball and hit squares, now it’s time to remove hit squares after a certain amount of time. There’s nothing new as we only have to work on contact listeners as explained in this post.

Let’s see the main class:

Let’s examine lines 14 and 16:

First I need to create a new custom contact listener, then I have to bind it to the world to use it in the simulation.

At this time we need to add some custom properties to boxes we are creating:

From lines 58 to 61 I’m attaching an Object to the box, whose properties are the name, the stamina and a Boolean variable called hit.

Now things will work this way: if a box is hit by the ball or by another box, that is if the box collides with any other body in the stage, hit is set to true and if hit is true its stamina will be decreased at every frame. Once the stamina reaches zero, the box is removed.

This routine will be placed in update function:

Lines 90-95 deal with stamina.

And that’s enough for main class, now we just have to extend the built in b2ContactListener
in a file called

The new class just set hit property to true if a box gets hit.

This is the result:

Mouse click to shoot the ball, try to hit a box and make the box hit more boxes, and see what happens.

Download the source code. Next time, we’ll add some graphics.

  • Tab

    Is like the bubble shooter!

  • It’s looking really cool! Plays a lot like their game!
    Weird thing happens when I scroll up/down to the demo on the page- all of a sudden there is a huge amount of blocks in the center calling down for a second before being removed, but they are removed pretty fast.

  • Well done emmanuele, btw I liked your input in Flash mindmeld

  • Arun K

    @Chris Moeller,

    I believe that behavior is something that is due the the flash player (versions from 10.1). When the embedded flash file is not in focus, i.e. the flash file is not in displayed right now on the screen and is somewhere else on the webpage, the flash player automatically reduces the frame rate (to about 2 FPS) to reduce the CPU cycles consumed by it.

  • DogGonMad

    To continue Arun K’s explanation, Flash does not render the frame when it is not in view, while timer events continue to fire, this causes the build-up.

  • 2zo

    Thank you for this tutorial. I’m really interested in the third step. Are you going to publish it any time soon?


  • yellowLine

    Thanks for tutorial.
    I want to rotate circles, too, but i can’t. Can you tell how?