Reputation: 13
I want to rota a sprite around a circle, but I couldn't do that. If I could not tell my problem you can understand from this picture:
Upvotes: 0
Views: 390
Reputation: 1098
Sprite
has a method setOrigin()
, https://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g2d/Sprite.html#setOrigin-float-float-
Set Sprite
's origin at the center of your circle and rotate it. Code will look similar to this:
float circleCenterX = ...;
float circleCenterY = ...;
float angle = ...;
Sprite sprite = ...;
sprite.setOrigin(circleCenterX, circleCenterY);
sprite.rotate(angle); // or sprite.setRotation(angle);
Upvotes: 2