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

Chapter 8. Getting Physical – Box2D

It's time to tackle physics! Cocos2d-x comes bundled with Box2D and Chipmunk. These are so-called 2D physics engines – the first written in C++ and the second in C. Chipmunk has a more recent Objective-C port but Cocos2d-x must use the original one written in C for portability.

We'll be using Box2D for the examples in this book. The next two games I'll show you will be developed with that engine, starting with a simple pool game to illustrate all the main points about using Box2D in your projects.

In this chapter, you will learn:

  • How to set up and run a Box2D simulation

  • How to create bodies

  • How to use the debug draw feature to quickly test your concepts

  • How to use collision filters and listeners