Box2D for Flash Games

Box2D for Flash Games
eBook: $14.99
Formats: PDF, PacktLib, ePub and Mobi formats
save 15%!
Print + free eBook + free PacktLib access to the book: $39.98    Print cover: $24.99
save 37%!
Free Shipping!
UK, US, Europe and selected countries in Asia.
Also available on:
Table of Contents
Sample Chapters
  • Design blockbuster physics game and handle every kind of collision
  • Build and destroy levels piece by piece
  • Create vehicles and bring them to life with motors

Book Details

Language : English
Paperback : 166 pages [ 235mm x 191mm ]
Release Date : November 2012
ISBN : 1849519625
ISBN 13 : 9781849519625
Author(s) : Emanuele Feronato
Topics and Technologies : All Books, Game Development, Games, Open Source

Table of Contents

Chapter 1: Hello Box2D World
Chapter 2: Adding Bodies to the World
Chapter 3: Interacting with Bodies
Chapter 4: Applying Forces to Bodies
Chapter 5: Handling Collisions
Chapter 6: Joints and Motors
Chapter 7: Skinning the Game
Chapter 8: Bullets and Sensors
  • Chapter 1: Hello Box2D World
    • Downloading and installing Box2D for Flash
    • Hello Box2D World
    • Defining the Box2D World
    • Running the simulation
    • Summary
    • Chapter 2: Adding Bodies to the World
      • Your first simulation – a ball falling on the floor
      • Creating a circular shape
      • Creating a fixture
      • Using debug draw to test your simulation
      • Creating a box shape
      • Different body types – static, dynamic, and kinematic
      • Density, friction, and restitution
      • Creating a Totem Destroyer level
      • Creating compound bodies
      • Creating an oriented box shape
      • Creating any kind of convex polygons
      • Summary
      • Chapter 3: Interacting with Bodies
        • Selecting and destroying bodies with a mouse click
        • Assigning custom attributes to bodies
        • Looping through bodies and getting their properties
        • Summary
        • Chapter 4: Applying Forces to Bodies
          • Falling apples, revamped
          • Force, impulse, and linear velocity
          • Applying an impulse to get a linear velocity
          • Applying a force to get a linear velocity
          • Forces in a real game
          • Physics games aren't just a matter of physics
          • Placing the physics bird
          • Shooting the physics bird
          • Summary
          • Chapter 5: Handling Collisions
            • Checking for collisions
            • Box2D built-in collision listener
            • Trace the beginning and the end of a collision
            • Detect when you are about to solve a collision and when you have solved it
            • Detecting when the idol falls on the floor in Totem Destroyer
            • Destroying bricks and killing pigs in Angry Birds
            • Summary
            • Chapter 6: Joints and Motors
              • Picking and dragging bodies – mouse joints
              • Keeping bodies at a given distance – distance joints
              • Making bodies rotate around a point – revolute joints
              • When Angry Birds meets Crush the Castle
              • Controlling joints with motors
              • Controlling motors with keyboard
              • Don't let some bodies collide – filtering collisions
              • Putting it all together
              • Summary
                • Chapter 8: Bullets and Sensors
                  • Experiencing tunneling
                  • Preventing tunneling – setting bodies as bullets
                  • Allow bodies to overlap while detecting contacts with sensors
                  • Summary

                  Emanuele Feronato

                  Emanuele Feronato has been studying programming languages since the early eighties, with a particular interest in game development. He taught online programming for the European Social Fund and founded a web development company in Italy. As a game developer, he developed Flash games sponsored by the biggest game portals and played more than 70 million times, and now is porting most of them on mobile platforms. As a writer, he worked as technical reviewer for Packt Publishing and published a book about Flash game development. His blog,, is one of the most visited blogs about indie programming.

                  Code Downloads

                  Download the code and support files for this book.

                  Submit Errata

                  Please let us know if you have found any errors not listed on this list by completing our errata submission form. Our editors will check them and add them to this list. Thank you.

                  Sorry, there are currently no downloads available for this title.

                  Frequently bought together

                  Box2D for Flash Games +    XNA 3D Game Development By Example [Video] =
                  50% Off
                  the second eBook
                  Price for both: £8.99

                  Buy both these recommended eBooks together and get 50% off the cheapest eBook.

                  What you will learn from this book

                  • Create a physics world with gravity
                  • Manage materials assigning physics properties
                  • Interact with physics bodies using mouse or keyboard
                  • Build vehicles with joints and motors
                  • Handle every kind of collision
                  • Add forces and impulses to bodies
                  • Turn your graphic assets into physics bodies
                  • Fire bullets and destroy bodies

                  In Detail

                  Physics games are getting more and more popular, and Box2D is the best choice if you are looking for a free, stable and robust library to handle physics. With Box2D you can create every kind of 2D physics game, only coding is not the fun part, but the game itself.

                  "Box2D for Flash Games" will guide you through the process of making a Flash physics game starting from the bare bones and taking you by hand through complex features such as forces, joints and motors. As you are learning, your game will have more and more features, like the physics games you are used to playing.

                  The book analyzes two of the most played physics games, and breaks them down to allow readers to build them from scratch in a step-by-step approach.

                  By the end of the book, you will learn how to create basic primitive bodies as well as complex, compound bodies. Motors will give life to cars, catapults and siege machines firing bullets, while a complete collision management will make your game look even more realistic.

                  If you want to make full Flash games with physics, then Box2D for Flash Games will guide you through the entire process of making a Flash physics game.


                  This book is a step by step guide to create games with Box2D explained in a simple and friendly way.

                  Who this book is for

                  Are you familiar with ActionScript3 and want to explore the capabilities of physics in game design using Box2D, then this book is for you. You don’t have to be an AS3 hero: if you know how to create classes and functions with AS3, then you can make your first physics game!

                  Code Download and Errata
                  Packt Anytime, Anywhere
                  Register Books
                  Print Upgrades
                  eBook Downloads
                  Video Support
                  Contact Us
                  Awards Voting Nominations Previous Winners
                  Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
                  Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software