0
\$\begingroup\$

I am confused . what shall I set the orthographic camera viewport in libGDX when I use box2d , in one tutorial I saw that he divided his viewport numbers to 32 because 1meter =32 pixel , but I think it will make the images to be displayed by lower quality , so can anybody explain me what viewport shall I set ?

\$\endgroup\$
2
\$\begingroup\$

I think you need to find the needed ratio between Texture size and meters. I would probably use 100px:1m. Then, when you are setting the fixture sizes, multiply the texture size with the ratio.

Try something like this:

//RATIO
private float ratio = 1/100;

// TEXTURE
private Texture texture = new Texture(YOUR TEXTURE PATH);

private float fixtureHeight = texture.getHeight() * ratio;

So now, if your player will be 200px heigh, then ,in box2d, it will be 2 meters high.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.