THEME IS CLOSED
> Physical Box2D engine and its use in libGdx | All platforms
Minegamer054
Message#1
26.06.17, 19:00
Local
*****
[offline]

Group: Friendssavagemessiahzine.com
Messages 141
Check in: 08.01.17
Samsung Galaxy Note 5 SM-N920F

Reputation:-  22  +

Физический движок Box2D и использование его в libGdx download



Attached Image


Device or OS, firmware:All platforms

26.06.2017

Since onsavagemessiahzine.comthere is almost no information about Box2D (and even more use in AIDE), I decided to create this theme. Maybe someone understands it.

Made by:
Ofthe mostnormal documentation for Box2D I managed to find onlyofficial, also dug library for libGdx with embedded Box2DAttached filegdx (rename to jar) .rar(1.41 MB)


Files:
[attachment = "10573063: release_gdx (rename to jar) .rar"


Examples (photo)
Attached ImageAttached ImageAttached ImageAttached Image



Post has been editedMinegamer054 - 19.11.17, 04:10
Reason for editing: Completed
Minegamer054
Message#2
28.06.17, 12:21
Local
*****
[offline]

Group: Friendssavagemessiahzine.com
Messages 141
Check in: 08.01.17
Samsung Galaxy Note 5 SM-N920F

Reputation:-  22  +

The first acquaintance with Box2D

A little bit with Box2D I still managed to figure out

This package, as I understand it, is not so complicated
// Box
boxDef = new BodyDef ();
boxDef.position.set (0,800);

boxDef.type = BodyDef.BodyType.DynamicBody;
box = world.createBody (boxDef);
box.setTransform (0,800,45);

rect = new PolygonShape ();
rect.setAsBox (200,100);
box.createFixture (rect, 20);


World
Worldis a certain space in which objects can be located (Body), move or interact with each other. World is called and used like this:
World world;
public void create () {
world = new World (new Vector2 (0, -10), true);
/ * new Vector2 creates a repository of coordinates (you can also create it separately, not directly in the method) which in this case is used to create graphitization. The first value is responsible for the extent to which all dynamic objects in the world will fall in X. With the second value, everything is also only in Y. Next comes the boolean variable that is responsible for if the objects “sleep”. Ie during rest, the object will become static (as I understood it). * /
}

World is also responsible for creating items

Body
Bodyis the container (probably) which can be projected on the screen and manipulated with it.
Body box;
public void create () {
...
box = world.createBody (BodyDef); // Create Body in the "world"
box.setTransform (0,800,45); // Method for changing the location of the Body, on the principle (x, y, angle)
box.createFixture (Fixture, 0); // Specify the shape of our object and its density
...
}


YandexDisk example

Box2DDebugRenderer
Box2DDebugRendererdisplays the edges of the created items. It can be used in cases when you haven’t painted textures yet, so that you can quickly correct any errors.

It is not recommended to use this constructor in the release game, since, firstly, it is intended for debug, and secondly, when creating an object from several forms, they will be visible all at once and cross.

It is used very simply:
Box2DDebugRenderer debug;
public void create () {
...
debug = new Box2DDebugRenderer ();
...
}
public void render () {
...
batch.begin ();
debug.render (world, batch.getProjectionMatrix ());
batch.end ();
...
}


I think there is nothing to explain here, since everything is very simple.

P.S.ATdocumentationdescribes methods for displaying certain types of objects, fixtures ...



Bodydef
Coming soon

PolygonShape
Coming soon

Box2D and AIDE
Coming soon


Post has been editedMinegamer054 - 30.06.17, 20:49
Reason for editing: Added Box2DDebugRenderer tutorial


--------------------
Do not forget to put+to this post
Zyomich
Message#3
01.05.18, 14:41
Odd // see signature
*********
[offline]

Group: Honorary Gameday
Messages 4288
Check in: 25.09.12

Reputation:-  744  +

M
Due to the long absence of activity, the topic is closed and moved to the archive.
If you need to add something to the topic, you can contact any section moderator.Android - Development and Programming


--------------------
But to betray is easy and simple, easy and simple to sell. And it's not very difficult to lie, About what is needed and what is possible В© Lumen- my opinion about the situation on the forum
Now you can not look for me here, I will never come here again, because I do not want to (23.11.18)



 mobile version    Now: 20.05.19, 08:34