Build 10 classic Flash games and learn game development along the way with this ultra-fast paced game development course.

If you love this blog, this is the book for you.

Buy the book

Get the source code of 12 commercial Flash games, which have been loaded more than 50 million times!

Learn from real world successful examples.

Get it now

Box2D for Flash Games teaches you how to make Flash physics games from scratch with the most advanced features.

Create the new Flash game smashing hit.

Buy the book

Box2D flying arrows engine – first attempt

This is an uncommented and unoptimized attempt to make an arrow engine. I used the third example of my Flying arrows simulation with Box2D, added the lines to have the camera following the latest arrow fired taken from Develop a Flash game like Angry Birds using Box2D – Following bird with the camera and skinning crates and played with a custom contact listener to add different behaviors to arrow-wall collision, arrow-crate collision and arrow-arrow collision.

I got also inspired by iforce2D sticky projectiles, and this is what I made:

Click on the stage to shoot an arrow from x=50, y=240 according to the angle between such coordinate and mouse pointer.

This is the main class:

and this is the custom contact listener:

Next time, I’ll add some improvements like a real bow firing arrow at different speed. Meanwhile feel free to give feedback or suggestions.

Rate this post: 1 Star2 Stars3 Stars4 Stars5 Stars (21 votes, average: 5.00 out of 5)
Loading ... Loading ...
Flash Templates provided by Template Monster are pre-made web design products developed using Flash technology.
They can be easily customized to meet the unique requirements of your project.
Be my fan on Facebook and follow me on Twitter! Exclusive content for my Facebook fans and Twitter followers

This post has 9 comments

  1. Cody

    on December 14, 2012 at 3:29 pm

    This is truly great, you are an inspiration!

  2. André Fellipe

    on December 14, 2012 at 5:07 pm

    Awesome! Some little optimizations and it will be perfect!

  3. [??]Box2D????-???? » Luo????

    on December 15, 2012 at 3:09 pm

    [...] ?????http://www.emanueleferonato.com/2012/12/14/box2d-flying-arrow-engine-first-attempt/ [...]

  4. MC

    on December 15, 2012 at 9:50 pm

    Suggestions:
    - zoom in / zoom out / cam-movement
    - Control the arrow speed/power
    - graphic textures

  5. Box2D flying arrows engine – first attempt – Emanuele Feronato « eaflash

    on December 17, 2012 at 10:36 am

    [...] on http://www.emanueleferonato.com Share this:TwitterFacebookLike this:LikeBe the first to like [...]

  6. Shekhar Suman

    on December 17, 2012 at 11:26 pm

    Please check my website. I’ve tried to accomplish the same using Box2dWeb.
    http://adf.ly/G5gMb

  7. Husky

    on December 18, 2012 at 4:27 am

    This is COOL!!!!!!!

  8. Franklin

    on January 2, 2013 at 5:56 am

    @MC plus one for the suggestions

  9. Ray Kutro

    on March 1, 2013 at 1:53 pm

    Great stuff really… I’m waiting for the next part with real bow. Thanks