Game Development Reference
In-Depth Information
Dynamic : This is a movable body. The position can be manually updated
or changed according to forces, which is the preferred and more reliable
method. Dynamic bodies can collide with all body types. It is useful for
players, enemies, items, and so on.
In a real-world scenario, humans and other movable items are
always dynamic, and they collide with others. However, the
ones that do not move such as trees, house, floor, and so on are
classified as static; they won't go toward the dynamic objects but
the dynamic objects can come and collide with them. Kinematic
objects are those that don't respond to force; they would move in
a predefined path according to a set velocity. An elevator would
be a good example.
Using shapes
Shapes describe the 2D objects in a geometrical way using radiuses for circles, widths
and heights for rectangles, or a certain number of points (also vertices) for more
complex shapes using polygons. So, these shapes define areas that can be tested for
collisions with other shapes later on. For more information about creating polygon
shapes, see the Box2D manual, 4.4 Polygon Shapes .
Using fixtures,
A fixture uses exactly one shape to which it adds material properties, such as
density, friction, and restitution. The shape defined in a fixture is then attached to a
body by adding the fixture to it. So, it plays an important role in how bodies interact
with each other. For more information about using fixtures, see the Box2D manual,
6.2 Fixture Creation .
Simulating physics in the world
The world is the virtual sandbox inside which the physics simulation takes place.
Each body, including its fixture and shape, needs to be inserted into the world to be
included in the simulation.
Box2D is a very feature-rich engine and thus contains a lot more features, such as
Constraints , Joints , Sensors , and Contact Listener just to name a few, but which are
not in the scope of this chapter.
For more in-depth information, consult the official manual of Box2D at http://www.
box2d.org/manual.pdf .
 
Search WWH ::




Custom Search