Reputation: 155
I use one camera at the moment to draw the Box2DDebugRenderer and one for drawing the map from the tmx. file. My problem is that, although the cameras have the SAME definition. The camera that is used for drawing the map is way too big on the screen.
SCREENSHOT Of the Problem:
Definition for box2dCam:
b2dCam = new OrthographicCamera();
b2dCam.setToOrtho(false, Game.getWidth() / PPM, Game.getHeight() / PPM);
b2dCam.update();
Definition for regular Camera:
cam = new OrthographicCamera();
cam.setToOrtho(false, Game.getWidth() / PPM, Game.getHeight() / PPM);
cam.update();
PPM (pixels per meter) is 32.
Code Game-class (regular camera is getting defined there!):
Code for Play-GameState (box2dCam get's defined and also both cams get moved to player position):
Anybody has any idea why that happens?
Upvotes: 2
Views: 575
Reputation: 19776
Definition for box2dCam:
b2dCam = new OrthographicCamera();
b2dCam.setToOrtho(false, Game.getWidth() / PPM, Game.getHeight() / PPM);
b2dCam.update();
Definition for regular Camera:
cam = new OrthographicCamera();
cam.setToOrtho(false, Game.getWidth(), Game.getHeight()); // <--
cam.update();
That's how it should be. Don't divide the tiled map's camera's viewport by the PPM ratio, since here you want it to be 1 unit = 1 px.
Upvotes: 2