If I understand correctly, LibGDX is rotating an image with the use of the addActions method:
this.addAction( parallel(rotateBy(360, 0.5f), moveTo(320, 100, 0.5f)));
The thing is, it is being rotated by the point=(0,0) of the image.
Here's my question:
Is there a way to rotate an image by the center point of the object? Something like pinning it in the middle and then turning it like a wheel in a car? Both rotateBy and rotateTo methods turn it by the (0,0) point of the image itself.
You have to properly set the "origin" of you actor. You can read from the Actor API that the origin is relative to the position and is used for scale and rotation.
So, calculate your middle point, and set origin to middle point.
Actor a;
....
a.setOrigin(a.getWidth()/2, a.getHeight()/2);
The easiest and shortest way I found for setting the origin is to call:
Actor a;
...
a.setOrigin(Align.center);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With