Green_qaue
Green_qaue

Reputation: 3661

libgdx how does x,y change when screen-size changes?

I'm fairly new to libgdx, and I need to place images in windows in a house. As I understand it, as long as I use orthographicCamera at (0,0), this will deal with the resizing for me, might be wrong here, but haven't looked into it that much yet.

So to my question: If I need to place images on the screen using constants like DrawImage(image, 50, 20); as I need to in my game because they need exact positioning. is there anything like androids dencity pixels to use? In android I would place it like this: DrawImage(image, 50*dp, 20*dp) and it would be on the same place on all screens, is there anything like this in libgdx? Or just any in-built method that I dont know of? My impression of libgdx so far is that it is very good with fixing these "boring" tasks for you somehow.

Upvotes: 1

Views: 141

Answers (1)

Daahrien
Daahrien

Reputation: 10320

If you create an orthographic camera, lets say 480x320. Then you use constants to draw your images, the camera will fill the screen regardless of the device resolution, so it will be the same in all screens :)

Upvotes: 1

Related Questions