O'Reilly logo

Libgdx Cross-platform Game Development Cookbook by Alberto Cejas Sánchez, David Saltares Márquez

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Introducing more complex shapes

Basic shapes work great when you do not need high precision to detect collisions but sometimes you will require an extra level of detail where, for instance, your actors' head is a circle and the rest of the body is grouped into a rectangle.

Mixing basic shapes in order to get a more complex one is definitely a powerful tool but there are still some entities that you could not model, such as an empty glass where objects can fall into it.

Be aware that this significant precision improvement has consequences on CPU consumption, so try to keep your body as simple as possible.

Getting ready

To follow this sample, you will need the Box2D physics editor created by Aurelien Ribon, which is downloadable from https://code.google.com/p/box2d-editor/downloads/list ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required