I’ve mad use of view ports and they do what they say they do, but the problem is I’m not able to get it to scale the whole world with it. The game is for android which it looks nice on but desktop is a little tricky. I tried changing the virtual size which made it unpleasing. I tried resizing it in the resize method, but that didnt help either. Here’s some code I have for the camera and viewport. I constantly check if the player is out of bounds as well.
//screen dimensions made for phone
screenW = 800, screenH = 400;
show() {
//Util
cam = new OrthographicCamera();
cam.position.set(screenWidth / 2, screenHeight / 2, 0);
vp = new ExtendViewport(screenWidth, screenHeight, cam);
}
resize(width, height) {
vp.update(width, height);
}
So this scales the sprites nicely but the world coordinates get a little weird. I made it so if the player’s x and y is greater than the screenW and screenH it pushes the player back and the bounds for that are still 800 by 400 like I set it. I tried setting the screenW and H to Gdx.graphics.getWidht() and height, but its seems the camera’s coordinates mess that up. The player is able to go past the screen size.
From the time I’ve spent researching, there’s just been links to the docs for this but I don’t think any of the Viewports are doing the job right. How can I get the whole game to scale towards the window size? Unprojecting the player location isnt working either and I’d really like to know what others are doing for their scaling.