Java Question Problems with libdbx

geewiztech

Member
Licensed User
Longtime User
I have a really strange problem with my project (attached). When I add a building the size of the building changes dependent on the screen size, even though I'm adding them with a specific dip size.
 

Informatix

Expert
Licensed User
Longtime User
I have a really strange problem with my project (attached). When I add a building the size of the building changes dependent on the screen size, even though I'm adding them with a specific dip size.

You should read the chapter about the Camera in the tutorial.

In your application, you try to use pixels (DIP means "density independent pixel") with a different unit scale (1/32 of the size, set with SetToOrtho2). That cannot work.

Instead of setting globalWidth to Activity.Width, you should set it to the exact value used by libGDX = lGdx.Graphics.Width. Same thing for globalHeight. They are usually the same, but in some cases (that I can't remember) you may have different values so it's a good habit to use the right properties.
 
Top