You are previewing Box2D for Flash Games.
O'Reilly logo
Box2D for Flash Games

Book Description

Create amazing and realistic physics Flash games using Box2D

  • 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

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.

Table of Contents

  1. Box2D for Flash Games
    1. Table of Contents
    2. Box2D for Flash Games
    3. Credits
    4. About the Author
    5. About the Reviewers
      1. Support files, eBooks, discount offers and more
        1. Why Subscribe?
        2. Free Access for Packt account holders
    7. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
        1. Downloading the example code
        2. Errata
        3. Piracy
        4. Questions
    8. 1. Hello Box2D World
      1. Downloading and installing Box2D for Flash
      2. Hello Box2D World
      3. Defining the Box2D World
      4. Running the simulation
      5. Summary
    9. 2. Adding Bodies to the World
      1. Your first simulation – a ball falling on the floor
      2. Creating a circular shape
      3. Creating a fixture
      4. Using debug draw to test your simulation
      5. Creating a box shape
      6. Different body types – static, dynamic, and kinematic
      7. Density, friction, and restitution
      8. Creating a Totem Destroyer level
      9. Creating compound bodies
      10. Creating an oriented box shape
      11. Creating any kind of convex polygons
      12. Summary
    10. 3. Interacting with Bodies
      1. Selecting and destroying bodies with a mouse click
      2. Assigning custom attributes to bodies
      3. Looping through bodies and getting their properties
      4. Summary
    11. 4. Applying Forces to Bodies
      1. Falling apples, revamped
      2. Force, impulse, and linear velocity
      3. Applying an impulse to get a linear velocity
      4. Applying a force to get a linear velocity
      5. Forces in a real game
      6. Physics games aren't just a matter of physics
      7. Placing the physics bird
      8. Shooting the physics bird
      9. Summary
    12. 5. Handling Collisions
      1. Checking for collisions
      2. Box2D built-in collision listener
      3. Trace the beginning and the end of a collision
      4. Detect when you are about to solve a collision and when you have solved it
      5. Detecting when the idol falls on the floor in Totem Destroyer
      6. Destroying bricks and killing pigs in Angry Birds
      7. Summary
    13. 6. Joints and Motors
      1. Picking and dragging bodies – mouse joints
      2. Keeping bodies at a given distance – distance joints
      3. Making bodies rotate around a point – revolute joints
      4. When Angry Birds meets Crush the Castle
      5. Controlling joints with motors
      6. Controlling motors with keyboard
      7. Don't let some bodies collide – filtering collisions
      8. Putting it all together
      9. Summary
    14. 7. Skinning the Game
      1. Replacing debug draw with your own graphic assets
      2. Summary
    15. 8. Bullets and Sensors
      1. Experiencing tunneling
      2. Preventing tunneling – setting bodies as bullets
      3. Allow bodies to overlap while detecting contacts with sensors
      4. Summary
    16. Index