j0hnskot
j0hnskot

Reputation: 65

Origin and position difference

I'm learning the libgdx engine and i got difficulties understanding the difference of .setOrigin and .setPosition . Take the demo libgdx creates. What is the difference if i put 1f,1f on origin and what on position of the texture this demo uses?

Upvotes: 3

Views: 4358

Answers (1)

Daahrien
Daahrien

Reputation: 10320

The Origin is used for Scaling and Rotating transforms. For example, if you put the origin at the Center of your sprite (width/2, height/2). When you rotate it, it will rotate around its center.

The position is the bottom-left corner of your sprite in world coordinates.

What is the difference if i put 1f,1f on origin and what on position of the texture this demo uses?

On origin it won't make any difference if you don't rotate or scale the sprite. On position, it will change where the sprite is drawn.

Upvotes: 7

Related Questions