So I'm trying to learn my way in Libgdx and Box2d nowadays. But there are some concepts I don't get.

First is, scaling. Both in Box2D Manual (PDF one) and Libgdx documentation, they say that we should scale our bodies and entities between box and world to get desired effects. And they give an example of two constants to achieve this easily:

I was trying to make a bullet when I realized I never used these and so far (I am doing very little right now, exams for 1 month ) nothing went wrong. For example, here is my bullet constructor (Because I am just testing, I preferred to create both sprite and body in the same place):

Nothing is going wrong there and I did not scale a thing. So, why are we supposed to scale sprites and bodies to/from World to/from Box?And how do we do that? Because if you consider the constants they give as example, scaling is by 100. I have 32x32 images, so it will be 0.32x0.32...

Is it something relative and am I just assuming that 1 pixel = 1 meter?

And there is another question on my mind which is about creating bodies and entities.Where should I create body and entity? In the same class (maybe a createBody() method)? Or should I have a kind of 'Box Factory'? Or something else? What is your approach to that?

Scale:There is a speed-limit, so you need to scale down the world to have fast moving bodies/change something in the config (don't know if it's possible in libgdx), also it's not recommended.1 pixel = 1 m is a bad idea, bodies will move max 120 px/s.It's better to use a camera that handles the render-size, I wouldn't use pixelToBox2dMeter-values.

Create Box2d-stuff;Atm I am saving the objects in json-files so I don't need to "create" them manually.Some time ago, I used "createDefaultBox2dBody()" inside the entity.class,for creating different Bullets I had

This is the single most difficult concept I had to grasp when I was starting out with LibGDX and Box2D

At first, things may probably be fine, but I believe that if you choose to stick to 1 pixel = 1 meter... there comes a point where if you create object too big and too heavy just so you could render it the way you want on-screen, the physics simulation becomes inaccurate.

I hardly find time for learning (final exams etc) so I start small. I mean one thing a day, in 1 hour.

So when I read about that scaling thing and started to write my classes, I was waiting for the point where I will use the scaling constants I talk about. But because I only have one character and one 'enemy'. 2 days ago, I sat down and made a bullet. It does everything I'd expect from it, except for the speed Tank and bullet has the same speed. So I figured this is about scaling.

But I can't find out how I can fix this.

I just need to see some classes where the author had to scale the box to world, or scale the sprite to box.

Philbedy, I read these before. Actually I use both camera and spritebatch like they explain there. But I read them again, with paying more attention. Still I cannot find anything that would help me with designing a camera that handles render-size.I already use a camera and a spritebatch. I set the spritebatch projection matrix to camera.combined. Maybe that's what I should change?

Actually, my initial issue was not that. My bullet goes too slow. That should be because of scaling. I mean 1 pixel should be 5 or 10 meters so that I can slow down my ship and bullet seems like it's going faster I am thinking...

Ah... We had a big misunderstanding here. Probably my thread title is the cause of that. And instead of telling my real problem, I asked about the method I thought to be the solution to that.

I have a tank and a bullet. Although I apply 1000 N force to tank and 10000000 N force to the bullet, they move at the same speed. Because Box2D has a speed limit. I wanted to know how to overcome this.Not about zooming or scaling images. Actually, I ask about scaling between box2d and libgdx.

np just reduce the size of everything and zoom in -> the speed won't increase, but:steps:0. looks like always1. you reduce the size of all box2d-bodies2. you zoom in (camera)-> looks like always3. apply forces-> your bullet now seems to move faster (indeed it isn't moving faster).4. scale forces, so the tank will not be as fast as the bullet

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org