MeineHTMLCodes
MeineHTMLCodes

Reputation: 559

LibGDX: Where is the X-/Y-Coordinate of a camera?

I'm wondering how the orthographic camera in LibGDX is positioned. Is X bottom left or center or on right(etc)? And how it is with the Y? I know its a simple question, but I'm messing around with my cam at this moment and I need some help :D

Upvotes: 0

Views: 782

Answers (2)

frogatto
frogatto

Reputation: 29285

In LibGDX, we have lots of coordinate systems (not only LibGDX, this applies to other engines/frameworks too). Camera is also a game object like other objects and thus is positioned like other objects.

The only difference about cameras is that they don't have width and height in the same sense of other objects. They are always a zero size point and can capture a rectangle (which is called viewport) centered on this point.

In your game if you use only one camera, what you see is the viewport that the only existent camera captures. So, if a sprite is on (0, 0) and also your camera is on (0, 0), you'll see that sprite exactly on the center of your screen.

Upvotes: 1

icarumbas
icarumbas

Reputation: 1805

Libgdx camera coordinates is always CENTER of your screen.

For example if your viewportWidth and viewportHeight like

(800, 480) 

it's coordinates will be

(400, 240)

Upvotes: 2

Related Questions