Box2D is a pure C++ library with no dependencies on the CPU architecture, so a simple makefile
and Android.mk
script, similar to those found in the previous sections, would suffice to build the library. Using the techniques described in the previous section, we set up a simulation. We also have the frame buffer from the previous chapter, and we only render the boxes using 2D lines.
As a bonus, Erin Catto—the library author—provides a simplified version of Box2D. Once you are happy with just the boxes available, you can restrict yourself to using the BoxLite version.
Download the most recent source code from the library home page: http://box2d.org.
To start with Box2D, we adapt the standard sample for a slightly modified BoxLite version, which is included in this book’s materials. First, we declare the global
World
object:World* g_World = NULL;
Initialize it at the end of the
OnStartup()
routine:g_World = new World(Vec2(0,0), 10); Setup...