Platform game basics using Box2D

I wrote about Box2D Flash version about a year ago, then I published Playing with Box2DFlashAS3 and Create a Flash game like Totem Destroyer as examples covering what you can do with this library.

But I was really impressed by a thread on TriquiTips submitted by Hawdon called Box2DAs3 For Beginners! (read steps 1 and 2) that in my opinion deserves to be posted on this blog, to reach a wider public… because I know there is a lot of people looking for AS3 and Box2D and platform tutorials… and the prototype made by Hawdon merges them all this way:

Left-right to move and up to jump

This is the source code with some comments

I have to say I am quite impressed about this work and I am porting my platform engine using Box2D, and release some Box2D tutorials if this post gets a good feedback.

  • Daniel Rodriguez

    Really nice, Box2D makes a realistic game, more than the tile engine.

  • Hawdon

    Got to say, didn’t excpect you to post it on the blog…
    But thanks!

    I’m, too, very intérested to hear what ppl think.
    If there is a lot of good feedback I might too post some more tutorials.

  • I caught this on Triqui and somehow messed up during the tutorial. So glad to have a reminder to try it once again! :)

  • “I have to say I am quite impressed about this work and I am porting my platform engine using Box2D…”

    YAY! Made my week.

  • Dude

    It would be much better if you finish your engine first….I would really apreciate it :P

  • You should check out, and the world creation kit []

  • anlik

    I like your website and I come here every day,please go on the BOX2D engine tutorial.

    非常期待你的box 2d教程,也非常尊敬你,吼吼,请一定加油,我是一名FLASH GAME DEVELOPER,一直在关注你的网站,非常非常非常期待你的物理引擎教程

  • mrcool


  • Wow! Just awesome! I’m going to try to combine the previous platform engine with this one :D

  • ptz

    AWESOME! make more tutorials about box2d!!!

  • Yay! I got the ball up the wall!

  • Marius

    “…and I am porting my platform engine using Box2D…”

    That would be awsome!

  • oliver_l1

    awesome! box2d rocks!

  • mark

    box2d is awesome!!! because of this im going to learn as3!! please make more!!!!!

  • PGN

    Thanks for another great tutorial! Box2D is awesome. More Box2D please :D !

  • Pippo

    what we could do for the scrolling?

  • malte

    i get alot of errors when i try to compile your example with the latest box3d code. Is there a newer Verison availabe? Did you alot of customizations to the Box2D Classes?

  • sega

    Yeah, it’s not working for me either, but I only get one error on line 1.

    “5006: An ActionScript file can not have more than one externally visible definition: Box2d, body”

  • afk

    why making an tutorial it it’s full of errors ? :E

    yeah, sure, i can make changes to use for my project, but what if i have no time ? and for very beginners?

  • Pingback: Christina Friel: ActionScripting and Design » Box2D: AS3()

  • This tutorial it’s great, I was looking for something like this over the internet for a long time. However this example doens’t show how to scroll smothly the world like this game made with box2dAS3

    Does anyone know some tutorial that could explain that?

    Thank you

  • jfdurand

    I really like your work and constant progression. Go on! You do great!

    Just for you to know for linking bodies and graphics, i use this myself (the actor part):

    Hope it helps you someway!


  • raz

    Really good tutorial, but it seems to have a little bug: if you jump into the wall and keep the right arrow pressed, the hero stays stuck on the wall and does not fall as it should.

    Is there anyway to fix this?


  • Andrew

    to make this scroll do you just do that like normal and extend your Box2D bounding area?

  • Andrew

    since I guess that site went down this tutorial is really hard to follow. too many errors and with out the source I can’t figure them out!

  • tanks for sharing tutorial

  • How do we keep our player object from bouncing?!

  • Pingback: Ninja Robot Dinosaur » Blog Archive » AS3 Boot Camp – Learn to program Flash games in 30 days()

  • Jimbo

    OK! now I have translate this great tutorial to fit fro Box2dAS3_2.1alpha.

  • Artark

    How it slides if left or right = false?

  • Spi

    Interesting… teoreticaly it should rotate which is not normal for a player… but I couldn’t make it rotate… I don’t see any script code to prevent it from doing so.

  • I still have some troubles understanding core concepts of Box2D (such as continuous collisions), but your tutorial are of great help. Thank you very much! :)