Build 10 games and learn game development along the way in this fast paced game development course

Get the source code of 12 commercial games, loaded 50+ million times, and learn the secrets of game design

Learn how to make a successful Flash game from a real world example. Fully commented source code

Create realistic Flash physics games from scratch with advanced features, from Angry Birds to Crush the Castle

Create REAL explosions with Box2D – adding textures

Ok, you asked it, now you have it. Now the Box2D explosion prototype features bitmap textures and a commented source code.

I have to say a big thank you to Antoan Angelov for his version of the slicing engine as he allowed me to manage textures with no hassle.

So now basically an explosion is a number of cuts at a random angle, all passing for the same point, which is the origin of the explosion. Then, every resulting slice will have a linear velocity according to the distance between the center of the slice mass and the origin of the explosion.

So this is what you’ll get:

Click on a crate to make it explode.

And this is the full, commented source code:

and this is userData class:

And now let me see what kind of games can you make using this concept.

Download the source code.

Rate this post: 1 Star2 Stars3 Stars4 Stars5 Stars (23 votes, average: 4.78 out of 5)
Loading...Loading...
Learn how to make a successful commercial Flash game from a real world example: get the fully commented source code of Globez, a Flash game played millions of times which generated a four figure income. Limited copies available.

Get it now
Be my fan on Facebook and follow me on Twitter! Exclusive content for my Facebook fans and Twitter followers

This post has 14 comments

  1. Amit

    on January 17, 2012 at 5:01 pm

    I am not a flash developer…but still i am following you coz i get ideas from you. i also enjoy ur posts and demos. I like to play with ur demos ;) can u add “Reply” button to demos ?? coz i need to refresh the page, if i want to play with demo again and again :(

  2. Simon

    on January 17, 2012 at 11:24 pm

    Wow – that is pretty awesome. I wan’t to make a building demolition game with this. The only problem is my inability to finish projects. But thank you for this, as well as all your other inspiring articles.

  3. MC

    on January 17, 2012 at 11:25 pm

    Great!! i hope to learn something here, thanks :)

  4. NICE

    on January 18, 2012 at 1:15 am

    Whoah nice job there.

    Although I noticed that it lags after blasting boxes for awhile buuut… prototype.

    :D

  5. Michael

    on January 18, 2012 at 1:56 am

    Great job Erin & Antoan! True source of inspiration for game developers!

    I look forward to try and making this work on the iPhone

  6. MC

    on January 18, 2012 at 3:49 am

    Emanuele, have you ever considered to create a small game framework in as3? Or a small customizable library with useful functions like: create/delete, explode and slice box2d objects?

  7. Vilash V

    on January 18, 2012 at 7:06 am

    gr8! work..I always enjoy going through your posts and the way you come up with new ideas.

  8. NemoStein

    on January 19, 2012 at 3:31 pm

    Emanuele, ever tried HaXe?
    Would be great to see Box2d and Starling running under HaXe.

  9. Chris

    on January 21, 2012 at 7:57 pm

    Awesome, very super cool!

    I’ll be trying this out with my Android game- even being able to do one such explosion would add a ton of realism to some of the levels.

    You’re giving us tools/ideas to make awesome games!

  10. All you need to know about how to write Box2D game | Artits Rastas

    on February 16, 2012 at 5:31 pm

    […] Create REAL explosions with Box2D – adding textures […]

  11. Jamie

    on September 6, 2012 at 6:25 pm

    Hey just trying to implement this in something, im trying to get it to work when something collides against the box, however if i change clickedBody to be a passed in body, it doesn’t work and i cannot see why. It gets an error due to removal =s

  12. Molano

    on February 7, 2014 at 3:34 am

    is this make sense ? what do u think @emanuele

    bodyDef1.position.Set(posx/worldScale,posy/worldScale);
    bodyDef1.type = b2Body.b2_staticBody;
    color_block = new cblock();

    bodyDef1.userData = {assetName:”cblock”,assetSprite:color_block};
    color_block.x = posx;
    color_block.y =posy;

  13. Piotr Kundu

    on March 12, 2014 at 2:31 am

    A lot of bitching has been done about Emanuele on his coding style, books and source code for sales. There are at least one more coding style than there are developers in the world and the “Not invented here” signal strike me too. You could take this code more OOP or TDD and DI, but the fact is that the algoritm is there! The solution is not obscured by a choice of methodology or usage of advanced tricks. I’m using bits and peaces in a C++ application and I’m guessing this is AS3 and Flash? I couldn’t care less, since everything is laid out and I’m happy people like Emanuele spend their time putting stuff on the web. I’m happy that people like Erin write open source like Box2D making bird companies rich.

  14. gd

    on May 19, 2014 at 4:09 pm

    Hey, noob question. very new to box2d. where exactly do I put my flash sprites into the code, been trying to do it for 2 days now. no luck.

    any help would be awesome.

Thank you for the download!!

I hope you will find it useful and make something interesting out of it

To keep up to date with the blog, why don't you like my Facebook page and follow me on Twitter?

Want to learn more? Don't miss this:

Learn how to make a successful commercial Flash game from a real world example: get the fully commented source code of Globez, a Flash game played millions of times which generated a four figure income. Limited copies available.

Get it now

×