Book Image

Learning Cocos2d-JS Game Development

By : Emanuele Feronato
Book Image

Learning Cocos2d-JS Game Development

By: Emanuele Feronato

Overview of this book

Table of Contents (18 chapters)
Learning Cocos2d-JS Game Development
Credits
Foreword
Foreword
About the Author
About the Reviewers
www.PacktPub.com
Preface
9
Creating Your Own Blockbuster Game – A Complete Match 3 Game
Index

Chapter 8. Adding Physics to Your Games Using the Chipmunk2D Engine

In the previous chapter, you saw how to add physics to your games using Box2D. However, Box2D isn't the only physics engine supported by Cocos2d-JS; you can also feature physics in your games using the Chipmunk2D engine.

So the main question is: should you use Box2D or Chipmunk2D to add physics to your games? There isn't a right answer. Just use the one you feel the most comfortable with.

That's why, in this chapter, I will show you how to create the same Totem Destroyer game using Chipmunk2D, highlighting the similarities and differences between the two physics engines.

As you saw in the previous chapter, it's time to learn:

  • Configuring Cocos2d-JS to add Chipmunk2D engine to your games

  • Creating a physics space with gravity

  • Combining bodies and shapes to create a physics object

  • Creating a material

  • Creating static objects

  • Creating dynamic objects

  • Attaching sprites to physics objects

  • Selecting physics objects with the mouse or finger...