Scaling box2d bodies for different screen sizes.

Anything about development not directly related to libgdx, e.g. OpenGL, Android APIs etc.

Scaling box2d bodies for different screen sizes.

Postby mickenzyjoela » Sun Feb 03, 2019 11:29 pm

I am currently working with box2d on android and would like my box2d bodies to be scaled correctly when rendered on a difference sized screen. I decided to not use viewports for my game becasue there was always a compromise whether it be black bars (fitViewport), slightly too much screen on top/bottom (extendViewport), etc. And with a mobile game, I found that to be a problem.

My game is pretty much 100% box2d. Right now I am using a fixed PPM of 40. The bodies look fine on my main 1440p device but do not on a 800x440 device. I have read about just scaling the PPM value for different screen sizes but am not sure how to do that.

I tried something like:

PPM = screenHeight / 25

However this also didn't work for me.
mickenzyjoela
 
Posts: 1
Joined: Sun Feb 03, 2019 11:29 pm

Re: Scaling box2d bodies for different screen sizes.

Postby QuiIIraven » Mon Feb 04, 2019 8:41 pm

I think you did not understand the purpose of viewports.

how exactly should a different PPM ratio fix the problem of different aspect ratios and resolutions?
QuiIIraven
 
Posts: 45
Joined: Sat Jun 02, 2018 4:59 pm


Return to General Development

Who is online

Users browsing this forum: No registered users and 1 guest