Game Development Reference
In-Depth Information
6.
Update the state as fast as possible:
GenerateTicks();
}
The call to the GenerateTicks() function makes the actual update timing for the Android
version. It is implemented using the ideas from the Implementing timing in physics recipe
from this chapter.
How it works...
The Setup() function is a modiication of the original sample code from Box2D to set up a
physics scene. The modiication consists of deining a number of shortcuts to simplify the
scene assembly.
The functions CreateBody() and CreateBodyPos() create rigid bodies with speciied
positions, orientations, dimensions, and masses. The function AddGround() adds a static
immovable object to g_World , and the function CreateJoint() makes a new physical
attachment of one body to another.
In this sample scene there are also some joints connecting the bodies.
The application App4 produces the same results on Android and Windows, as in the following
image, which is one of the simulation steps:
There's more...
As an exercise, we suggest that you experiment with the settings, and add more of your own
2D scenes to the App4 sample.
See also
F Implementing timing in physics
 
Search WWH ::




Custom Search