I\'ve got a problem with Box2D
. I\'m making a simple 2D game, with a player shooting to enemies. I read that 1 unity in Box2D is equivalent to 1 meter so i shou
you don't have to use the zoom to handle this here what i do and it works very well for me
camera = new OrthographicCamera(SCREEN_WIDTH/PPM, Config.SCREEN_HEIGHT/PPM);
// fix camera to the center of the screen
camera.position.set(Config.SCREEN_WIDTH/PPM/2f, Config.SCREEN_HEIGHT/PPM/2f, 0);
camera.update();
i put the conversion unit (PPM) to 100
hope this was helpful
Good luck
Don't use PPM, i know you might have seen a lot of tutorials using PPM but instead use virtual pixels or potato pixel for camera and box2d. Here read this wonderful article and this answer. For example:
OrthographicCamera camera = new OrthographicCamera(20, 11);
Here 20 is any arbitrary number for WIDTH
and HEIGHT
should be actually WIDTH*Gdx.graphics.getHeight()/Gdx.graphics.getWidth()
.
You don't need to set any zoom level, leave it to default.