The conversion from a unit to another is a matter of a simple multiplication. You can implement a ConvertUnits
static class with functions like ConvertToGameUnits()
, and ConvertToBox2DUnits()
to make it easier.
I haven't used libgdx or Box2D, but i have used Farseer Physics engine which is basically identical with box2D but made for C#. With that being said, bodies simply help you with physics simulation, you don't link bodies with sprites. If you wanted to have a rectangle in your game, ConvertToBox2DUnits()
function to set the position/width/height of your rectangle, and then you would have to use the body.Position
property and your ConvertToGameUnits()
method, to draw your sprite on the current rectangle's position.
As for making your game look the same on every screen isn't exactly possible, since not every screen has the same aspect ratio with the game you are making. Lets say you want to draw a 720x1280(16:9) resolution texture on a 480x640(4:3) phone (horizontally). You would draw 50% less pixels (which is a simple scale down to 50%), and also you would have to either place black bars
on the top and bottom side of you phone or stretch the image to fit the screen.
I think you should first check some example game written in libgdx and/or box2D and start from there.