Is there a formula to calculate world unit or pixels per unit values in LibGdx?
Most of my objects fit into a 32x32 or 16x16 frame. When the objects are close to 32x32, and I use
1f as the size or 16x16 and use
.5f things seem to work out fine. What I try to do is use this:
// Create viewport that is used to as the game size static final float VIEWPORT_WIDTH = 15f; static final float VIEWPORT_HEIGHT = 7f; viewport = new FitViewport(VIEWPORT_WIDTH, VIEWPORT_HEIGHT); // Scale sizes final float UNIT_PIXEL = 0.03125f; // 1 / 32 float newSize = 32f * UNIT_PIXEL;
Which seems to work for 32x32 or 16x16. But size problems seem to happen when you try to use that to calculate other widths or heights. Like if I try to use:
float newSize = 24f * UNIT_PIXEL;
Using this the bounding rectangle becomes much larger than the object.