I use an angle to set the velocity (or direction if you prefer) of my sprite, however, I want the sprite to be heading in the same angle as I'm moving, rotating according to that angle.

How I set angle and velocity:

angle = (float)Math.atan2(0 - pos.y, 220 - pos.x); //using bottom mid of screen as destination for testing

//in update
pos.x += 200 * Math.cos(angle) * delta;
pos.y += 200 * Math.sin(angle) * delta;
sprite.setPosition(pos.x, pos.y);

//in render

is there any way to use this value in LibGdx's "sprite.rotate()" function? I can't do "sprite.rotate(angle)". Can I do this some other way? Can I convert my angle-value somehow to degrees? I'm stuck.

I tried


but that gave rly weird results, the following image is moving down and to the right


  • \$\begingroup\$ "rly wierd results" how? That says nothing about the result you got. \$\endgroup\$ Oct 10, 2015 at 0:41
  • \$\begingroup\$ Hmm, hard to explain, Ill post an image \$\endgroup\$
    – Green_qaue
    Oct 10, 2015 at 0:41
  • \$\begingroup\$ Is it the same as in stackoverflow.com/q/27345132/731620 ? \$\endgroup\$ Oct 10, 2015 at 0:45
  • \$\begingroup\$ I tried using sprite.setRotation((MathUtils.radiansToDegrees * angle)); but getting wrong result still. I dont actually rotate it in update, since it never changes direction I set the angle in the constructor, after the position has been set. \$\endgroup\$
    – Green_qaue
    Oct 10, 2015 at 0:51
  • \$\begingroup\$ @ratchetfreak added an image \$\endgroup\$
    – Green_qaue
    Oct 10, 2015 at 0:53

1 Answer 1


rotate takes I believe a relative rotation while angle is an absolute rotation. In other words take the difference between the current angle and the wanted angle and pass that to rotate.

Or pass just the angle into setRotation.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .