Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 446
j0hnskot Avatar asked Jul 20 '26 04:07

j0hnskot


1 Answers

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.

like image 157
Lestat Avatar answered Jul 24 '26 23:07

Lestat