Box2D for Flash Games
eBook - ePub

Box2D for Flash Games

  1. 166 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Box2D for Flash Games

About this book

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.

Approach

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!

Frequently asked questions

Yes, you can cancel anytime from the Subscription tab in your account settings on the Perlego website. Your subscription will stay active until the end of your current billing period. Learn how to cancel your subscription.
No, books cannot be downloaded as external files, such as PDFs, for use outside of Perlego. However, you can download books within the Perlego app for offline reading on mobile or tablet. Learn more here.
Perlego offers two plans: Essential and Complete
  • Essential is ideal for learners and professionals who enjoy exploring a wide range of subjects. Access the Essential Library with 800,000+ trusted titles and best-sellers across business, personal growth, and the humanities. Includes unlimited reading time and Standard Read Aloud voice.
  • Complete: Perfect for advanced learners and researchers needing full, unrestricted access. Unlock 1.4M+ books across hundreds of subjects, including academic and specialized titles. The Complete Plan also includes advanced features like Premium Read Aloud and Research Assistant.
Both plans are available with monthly, semester, or annual billing cycles.
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Yes! You can use the Perlego app on both iOS or Android devices to read anytime, anywhere — even offline. Perfect for commutes or when you’re on the go.
Please note we cannot support devices running on iOS 13 and Android 7 or earlier. Learn more about using the app.
Yes, you can access Box2D for Flash Games by Emanuele Feronato in PDF and/or ePUB format, as well as other popular books in Computer Science & Computer Science General. We have over one million books available in our catalogue for you to explore.

Box2D for Flash Games


Table of Contents

Box2D for Flash Games
Credits
About the Author
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers and more
Why Subscribe?
Free Access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Hello Box2D World
Downloading and installing Box2D for Flash
Hello Box2D World
Defining the Box2D World
Running the simulation
Summary
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
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
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
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
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
7. Skinning the Game
Replacing debug draw with your own graphic assets
Summary
8. Bullets and Sensors
Experiencing tunneling
Preventing tunneling – setting bodies as bullets
Allow bodies to overlap while detecting contacts with sensors
Summary
Index

Box2D for Flash Games

Copyright © 2012 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: November 2012
Production Reference: 1161112
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-84951-962-5
www.packtpub.com
Cover Image by Artie Ng ()

Credits

Author
Emanuele Feronato
Reviewers
Joseph Hocking
Ali Raza
Acquisition Editor
Mary Jasmine Nadar
Commissioning Editors
Priyanka Shah
Shreerang Deshpande
Technical Editor
Manmeet Singh Vasir
Copy Editor
Laxmi Subramanian
Project Coordinator
Shraddha Bagadia
Proofreaders
Maria Gould
Cecere Mario
Indexer
Hemangini Bari
Graphics
Aditi Gajjar
Production Coordinator
Prachali Bhiwandkar
Cover Work
Prachali Bhiwandkar

About the Author

Emanuele Feronato has been studying programming languages since the early 1980s, with a particular interest in game development. He taught online programming for the European Social Fund (ESF) and founded a web development company in Italy.
As a Game Developer, he has developed Flash games sponsored by the biggest game portals and his games have been played more than 70 million times, and he is now porting most of them on mobile platforms.
As a writer, he has worked as a Technical Reviewer for Packt Publishing and published the book Flash Game Development by Example, Packt Publishing.
His blog, www.emanueleferonato.com, is one of the most visited blogs about indie programming.

About the Reviewers

Joseph Hocking is an interactive media developer living in Chicago. He has spent many years developing Flash games for various companies and freelance clients, and currently works for Synapse Games developing games such as Tyrant and Skyshard Heroes. His development skills include programming web-based games in AS3/Flash, using JavaScript in web pages, writing Python for both client and server applications, and building iPhone games using Lua/Corona SDK.
In addition, Joe also teaches at schools such as the Game Development program at Columbia College. Besides graphics programming, he has a great deal of training and experience in digital arts, including 3D animation. A portfolio of his work can be viewed at www.newarteest.com.
Ali Raza has a master's degree in Computer Science, and more than 8 years of experience as a Designer and Developer. He is also an Adobe Certified Instructor (ACI) and a Microsoft Certified Trainer (MCT).
He is currently working with a UK-based social networking startup as a Senior Developer (Flash Platform), and as a Consultant with a US-based firm ProContent, LLC (team behind Advanced Flash Components). In the past, he has worked with different ...

Table of contents

  1. Box2D for Flash Games