Book Image

Cocos2d-x by Example: Beginner's Guide

By : Roger Engelbert
Book Image

Cocos2d-x by Example: Beginner's Guide

By: Roger Engelbert

Overview of this book

Table of Contents (19 chapters)
Cocos2d-x by Example Beginner's Guide Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

So what is a physics engine?


The famous Isaac Newton said, every action has a reaction. Right after he said, who the hell threw that apple?

So far in our games, we have covered very simple collision systems, basically only ever checking to see if simple shapes (circles and rectangles) overlapped each other. The reactions from these collisions were also very simple in our games so far: with vector inversions or simply by making things disappear once they touch. With Box2D, you get way more!

Box2D is a very robust collision detection engine and can certainly be used just for that purpose. But the simulation will also process and return a bunch of information derived from the collisions and the interactions between bodies, meaning how the objects should behave, based on their shapes, mass, and all the forces at play in the simulation.

Meeting Box2D

At the core of the engine, you have the b2World object. This is the simulation. You fill the world with b2Body objects, and then you step through the...