box2d official website: http://box2d.org/
box2d v2.1.0 User manual translation: http://blog.csdn.net/complex_ok/article/category/871440
LIBGDX uses JNI to encapsulate the C + + version number of box2d, making it much faster to perform than other peers ' physics engines such as jbox2d.
first, the basic class
Bodydef
A body definition holds all the data needed to construct a rigid body. You can safely re-use body definitions. Shapes is added to a body after construction.
All the data needed to define the body is up to it, and we can use it repeatedly.
The binding of shape and body must be completed after it.
This is what I understand to be able to define the type of object model, and so on, it into the body.
The common use method is to define the type:
Such as
Bodydef ballbodydef = new Bodydef (); Build object ballbodydef.type = bodytype.dynamicbody;//definition type, dynamicbody is an uncontrolled dynamic object, Kinematicbody is controlled dynamic object, Staticbody is a static object
Body
A rigid body. These is created via World.createbody.
This is a very hard object, do not want to change its shape. We can only create it through the World.createbody method.
Use methods such as the following (Ballmodels is body):
Ballmodels = World.createbody (ballbodydef);
Ballmodels.createfixture (FD);
Box2ddebugrenderer
A graphical display for test box2d. The shape of the graphic is drawn in different colors.
Chainshape, CircleShape, Edgeshape, Polygonshape
They all inherit from the Shap, which is the most important graphic
Fixture
Binds a shape to an object and has a certain material property, such as density (density). Must be generated by body.createfixture.
Fixturedef
The attribute declaration of the fixture. can be used repeatedly.
Fixturedef fd = new Fixturedef () fd.density = 1;//density fd.friction = 0f;//friction fd.restitution = 0.5f;//elastic 0-1,1 for fully elastic collision Fd.shape = shape;
World
The world class manages all physics entities, dynamic simulation, and asynchronous queries. The world also contains efficient memory management facilities.
Manage all physical entities, dynamic simulations, asynchronous queries.
It also includes an efficient memory management mechanism.
The physical world, managing all body,
Such as:
<span style= "color: #33cc00;" >world = New World (new Vector2 (0, -10f), false), or//represents the physical universe of downward gravitational acceleration of 10 </span>
<span style= "color: #33cc00;" ></span>
Because the physical world is inconsistent with the time in render, we typically convert by adding a sentence to the Render method:
World.step (1/60f, 10, 10);
At the same time, the physical world is at the center of the screen. And the stage is (0,0), I hope you can pay attention.
The length of the physical world is not calculated according to the pixel. Pay attention to unit conversions. The general conversion ratio is 1:60,. The physical world is 1.
Copyright notice: This article blog original article. Blogs, without consent, may not be reproduced.
LIBGDX box2d Reality---this sustained-release pellets (two: box2d introduction)