Game Development Reference
Time.fixDelta( Time.FPS30 );
d get a consistent value for the deltaTime ,no
matter how much time had actually passed. To undo this action,
simply pass in a value of 0 or less:
From then on, you
Time.fixDelta( 0 );
re welcome. Now to get back to the game at hand.
The engine for this game, as I
ve already mentioned, utilizes Box2D
for its physics simulation. However, before we get started in the
engine, here is a quick look at Box2D
ll be stay-
dig further, you can find a link to a fantastic series of tutorials at
s core principles. I
Box2D works in meters as its basic unit of measurement; one of
the first things to do when using the library is to establish your
conversion rate of pixels to meters. 30 pixels per meter is the
unofficial standard, because of how the simulation internally
handles its calculations.
Every element inside a Box2D simulation is a mathematical
construct. It knows nothing about display objects, so our engine
will be responsible for mapping the simulation objects to visuals
The coordinate space in which Box2D runs its simulation is
and is represented by an instance of the
b2World class. Objects in the world that take up physical space
represented by the b2Body class.
Bodies can be static, dynamic, or kinematic. Static bodies do
not respond to forces and do not move, like concrete walls.
Dynamic objects move freely and respond to forces in the world
(like gravity and impacts with other objects). Kinematic objects
(which we won
t use in our game) are ones that move but don
respond to force
a good example might be gears that rotate by
themselves and move other bodies.
Bodies are represented by shapes (such as squares, circles, and
triangles), and these shapes determine how they react in
collisions. However, shape objects do not have any knowledge of
the physical properties of the body, such as friction, density, and
so on. There is a separate kind of object, called a fixture , which is
used to define these properties for a body and bind it to a shape.
No objects in Box2D are created directly. Rather, definition or
objects are created, which are then passed to the world to
create the actual objects. Think of def objects such as blueprints
for the actual object to be created. You can use a def over and
over again, once the world uses it to create an object, it retains